can the sequence of entries in a dictionary be depended on?

Carsten Haese carsten.haese at gmail.com
Sun Nov 23 23:11:17 EST 2008


John Machin wrote:
> "the lists will directly correspond"? What does that mean? 

It means that e.g. zip(d.keys(), d.values()) == d.items() is guaranteed
to be True.

> Why not
> "the lists will be equal i.e. list1 == list2"?
> 
> How about "Provided that keys are neither added nor deleted, the order
> of iteration will not change"?

Neither of those convey the above guarantee.

--
Carsten Haese
http://informixdb.sourceforge.net



More information about the Python-list mailing list