python - How do you retrieve items from a dictionary in the order that they're inserted? -
is possible retrieve items python dictionary in order inserted?
the standard python dict
isn't able this.
there proposal (pep 372) add "ordered dictionary" (that keeps track of order of insertion) collections
module in standard library. includes links various implementations of ordered dictionaries (see these two recipes in python cookbook).
you might want stick reference implementation in pep if want code compatible "official" version (if proposal accepted).
edit: pep accepted , added in python 2.7 , 3.1. see the docs.
Comments
Post a Comment