The Order Of Dictionary Entries

Terry Reedy tjreedy at udel.edu
Wed Mar 10 12:28:01 EST 2004


"Tim Daneliuk" <tundra at tundraware.com> wrote in message
news:in93i1-ctp1.ln1 at eskimo.tundraware.com...
> I am aware that dictionary order is not guaranteed.  But I ran into
> something puzzling today.  I filled a dictionary dynamically as a
> program ran.  Up to a certain point, the key order was the order
> in which things were added.

I am rather certain that this was an accident dependent on you adding the
keys in the order in which they were going to displayed.  Try adding the
items in a different order and the display order should not change much if
at all.  Example:

>>> {1:1, 2:2}
{1: 1, 2: 2}
>>> {2:2, 1:1}
{1: 1, 2: 2}

Terry J. Reedy







More information about the Python-list mailing list