forcing dictionary order

Bob van der Poel bvdpoel at
Thu Mar 29 20:36:30 CEST 2001

I'd like (not a must!) to walk a dictionary in the same order in which
it was created. Example:

	foo={ key1: (), key2: (), key3: () }

If I do:
	for a in foo.keys(): ...

the order is not "key1, key2, key3", which is what I want. Note, I can't
do something simple like sort() on the keys since the are not in any
alphanumeric order. I'm just using this to generate a largish table for
another program, and the actual order doesn't matter for it to work
properly, but it would nicer if it were in the correct logical order.
So, I'm not going to spend a lot of time on this, but if there is a
simple way????

Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bvdpoel at

More information about the Python-list mailing list