dictionary: keys() and values()

Irmen de Jong irmen at NOSPAMREMOVETHISxs4all.nl
Thu Jun 13 18:00:42 EDT 2002


Andrew Koenig wrote:
> From the library reference, 2.2.7, footnote 3:
> 
> If keys() and values() are called with no intervening modifications to the
> dictionary, the two lists will directly correspond.  This allows the creation
> of (value, key) pairs using zip():  "pairs = zip(a.values(), a.keys())".

Why would you want to do that if you have .items()?

Irmen




More information about the Python-list mailing list