At 02:19 PM 6/15/2008 +0000, Antoine Pitrou wrote:
> Ordered dicts, dicts that remember the chronological order of their
> insertion, don't sound generally useful.
They are generally useful in any case where you want to handle key-value
pairs while not confusing a human operator by messing up the original order.
Think e.g. configuration files. A common complaint against ConfigParser is
that writing a configuration file does not preserve the order of the original
file, which is harmless for the computer but very annoying for the human
being who maintains that file.
You don't need an ordered dictionary for that; you need a save
routine that stream-edits the old file contents. That way, you don't
lose comments and spacing either.
As for the other uses for ordered dictionaries, I find it simplest to
just use a list of key,value pairs, and only transform it to a
dictionary or dictionary-like structure as needed, using tools like
the cgi module, the email package, or wsgiref.headers.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com