how to keep order key in a dictionary
BartlebyScrivener
bscrivener42 at gmail.com
Sun Nov 4 09:35:30 EST 2007
On Nov 4, 7:19 am, azrael <jura.gro... at gmail.com> 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"""
keys = dict.keys()
keys.sort()
for key in keys:
print key, ":", dict[key]
from Python Visual Quickstart, Chris Fehily p. 157
More information about the Python-list
mailing list