On Tue, May 6, 2008 at 9:26 AM, Jeremy Sanders <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > Hi - further to my earlier query regarding partial matches (which with > > all your replies enabled me to advance my understanding, thanks), I > > now need to reverse a dict. > > There is no guaranteed order to the items stored in a dictionary. They can > and will move around as the dict is modified. Have a look at > diveintopython: > > http://www.diveintopython.org/getting_to_know_python/dictionaries.html > > You'll have to store your keys in a list or tuple to keep them ordered.
You might also take a look at the odict[1] or ordereddict[2] modules. [1] http://www.voidspace.org.uk/python/odict.html [2] http://www.xs4all.nl/~anthon/Python/ordereddict/ -- http://mail.python.org/mailman/listinfo/python-list