Re: how to keep order key in a dictionary

2007-11-04 Thread Bruno Desthuilliers
azrael a écrit : > 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 > importan

Re: how to keep order key in a dictionary

2007-11-04 Thread azrael
thanks, the links where successfull -- http://mail.python.org/mailman/listinfo/python-list

Re: how to keep order key in a dictionary

2007-11-04 Thread BartlebyScrivener
On Nov 4, 7:19 am, azrael <[EMAIL PROTECTED]> wrote: > For this dictionary it is realy > important to keep the right order. Is it possible to arange them in a > specific order? Not sure what order you want, but how about sorting the keys? def printdict(dict): """print sorted key:value pairs"""

Re: how to keep order key in a dictionary

2007-11-04 Thread Jeff McNeil
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, azra

how to keep order key in a dictionary

2007-11-04 Thread azrael
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.