Why are there no ordered dictionaries?

Christoph Zwerschke cito at online.de
Wed Nov 23 17:31:19 EST 2005


Fuzzyman wrote:

> That's not the only use case. Other use cases are to have a specific
> order, not based on entry time.
> 
> Simple example :
> d1 = OrderedDict(some_dict.items())
> d1.sequence.sort()
> d1 is now an ordered dict with the keys in alphabetic order.

As I said, I would not need to access the sequence, if I can write
d1.sort() or d1.sortkeys()

> If you don't want to modify sequence, don't. If you want a copy do :
> seq = d1.sequence[:]

This is not needed since you can do the same with: seq = d1.keys()

-- Christoph



More information about the Python-list mailing list