dictionary method question
Erik Max Francis
max at alcyone.com
Tue Apr 23 15:52:20 EDT 2002
dsavitsk wrote:
> for some dictionary d is there any relationship between the returns from
> d.keys() and d.values()? that is, to get them in some arbitrary but
> matching order, do i need to loop over d.items() or can i count on a
> similarity of the above? in small tests this seems to be the case.
I presume they would return values in the same object order, but I
wouldn't count on it. The .items method is designed expressly for that
purpose anyway; you're better off using .items since it's potentially
faster than zipping the two lists together yourself, and it's clearer
anyway.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
\__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ I like young girls. Their stories are shorter.
\__/ Thomas McGuane
/ Kepler's laws / http://www.alcyone.com/max/physics/kepler/
A proof of Kepler's laws.
More information about the Python-list
mailing list