dictionary: keys() and values()

holger krekel pyth at devel.trillke.net
Thu Jun 13 18:09:50 EDT 2002


Irmen de Jong wrote:
> 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()?

i almost fell for the same question untill i looked harder<wink>.

order-sometimes-matters-ly y'rs, Holger





More information about the Python-list mailing list