In what order does Python read dictionary keys?
tcpeter at my-deja.com
tcpeter at my-deja.com
Tue Jun 8 19:27:13 EDT 1999
In article <375D8077.EA539C6D at pop.vet.uu.nl>,
M.Faassen at vet.uu.nl wrote:
> tcpeter at my-deja.com wrote:
>> when I ran the code, the options were
presented
> > in the desired order. (A trifle creepy, if you ask me. Turing would
be
> > delighted.) Anyway, how does Python decide the order. Thanks.
>
> Hi there,
>
> The answer is that Python doesn't have any set orders for
dictionaries.
> The internal hashing algorithm the python dictionary uses has no
> guaranteed order. So basically you shouldn't depend on any particular
> order it produces.
OK. So is there a way to ensure a specific order? In this instance
I've given it's not particularly critical, but there are times where it
might be. Any ideas?
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
More information about the Python-list
mailing list