move to end, in Python 3.2 Really?

Carl Banks pavlovevidence at gmail.com
Tue Jan 18 00:20:19 EST 2011


On Jan 17, 6:51 pm, nn <prueba... at latinmail.com> wrote:
> I somehow missed this before. I like most of the additions from
> Raymond Hettinger. But the api on this baffles me a bit:
>
> >>> d = OrderedDict.fromkeys('abcde')
> >>> d.move_to_end('b', last=False)
> >>> ''.join(d.keys)
>
> 'bacde'
>
> I understand that "end" could potentially mean either end, but would
> "move_to_end" and "move_to_beginning" not have been clearer?

It's a minor issue, but I'd tend to lean that way.  Most other times
when something can happen on one end of a sequence or another, it uses
different function calls.  E.g.: startswith vs endswith, lstrip vs
rstrip, and even pop vs popleft.

Oddly, Hettinger seems to be a big advocate of not overloading
functions.


Carl Banks



More information about the Python-list mailing list