Alex Rivera | Logout

How do you retrieve items from a dictionary in the order that they're inserted?

Asked 2008-09-13T20:38:05.467
69

Is it possible to retrieve items from a Python dictionary in the order that they were inserted?

Edit
Report

1 Answer

1

Or use any of the implementations for the PEP-372 described here, like the odict module from the pythonutils.

I successfully used the pocoo.org implementation, it is as easy as replacing your

my_dict={}
my_dict["foo"]="bar"

with

my_dict=odict.odict()
my_dict["foo"]="bar"

and require just this file

answered 2009-03-18T19:42:29.707

Your Answer