indexed dictionaries?

Michal Wallace (sabren) sabren at manifestation.com
Mon Apr 10 04:30:24 CEST 2000


Hey all,

  I just KNOW this has been done before, but I can't seem to find an
example... I'm looking for a cross between a dictionary and a list,
such that keys() always returns keys in the order in which they were
added, and that instance[0] refers to the first key...

eg:

>>> import IdxDict
>>> x = IdxDict()
>>> x["a"] = "first one"
>>> x["b"] = "second one"
>>> x[0]
'first one'
>>> x["a"]
'first one'
>>> x.keys()
('a', 'b')

Anyone got something like this?  

Thanks,

- Michal
-------------------------------------------------------------------------
http://www.manifestation.com/         http://www.linkwatcher.com/metalog/
-------------------------------------------------------------------------





More information about the Python-list mailing list