how to keep order key in a dictionary

Jeff McNeil jeff at jmcneil.net
Sun Nov 4 14:52:05 CET 2007


See http://www.python.org/doc/faq/general/#how-are-dictionaries-implemented 
.  In short, keys() and items() return an arbitrary ordering.  I think  
that http://pypi.python.org/pypi/Ordered%20Dictionary/ will do what  
you want if key ordering is a necessity.

Jeff
On Nov 4, 2007, at 8:19 AM, azrael wrote:

> I 'm currenty working on a project for which it would be great to use
> a dictionary. At the begining I have a list of strings that should
> represent the keys in the dictionary. When I try to create a
> dictionary it rearanges the keys. For this dictionary it is realy
> important to keep the right order. Is it possible to arange them in a
> specific order?
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list