access dictionary with preferred order ?

bonono at gmail.com bonono at gmail.com
Sat Oct 22 06:18:52 CEST 2005


Hi,

I am wondering if there is a dictionary data type that allows me to
define the order of access when iterating it using items/keys etc. ?

An example:

a=dict(a=dict(), c=dict(), h=dict())
prefer=['e','h', 'a']

for x in a.values: print x

would give me
{h:dict()}, {a:dict()}, then the rest which I don't care about the
order ?




More information about the Python-list mailing list