Why are there no ordered dictionaries?
Christoph Zwerschke
cito at online.de
Sun Nov 27 06:41:12 EST 2005
Bengt Richter schrieb:
> OTOH,
> >>> {}[:]
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: unhashable type
> I.e., slices are not valid keys for ordinary dicts, and slices tie in
> very well with the ordered aspect of ordered dicts, so that's an
> argument for permitting it via the indexing syntax, not just items[:]
> or items()[:] which have related but not identical semantics.
I see it like that. BTW, the above error message is pretty bad.
> I wonder who is going to use it for what.
I think re-ordering will be a very rare use case anyway and slicing even
more. As a use case, I think of something like mixing different
configuration files and default configuration parameters, while trying
to keep a certain order of parameters and parameters blocks.
-- Christoph
More information about the Python-list
mailing list