dict.keys() and dict.values() are always the same order, is it?

Cameron Simpson cs at zip.com.au
Tue Apr 20 01:23:12 EDT 2010


On 19Apr2010 21:31, alex23 <wuwei23 at gmail.com> wrote:
| Cameron Simpson <c... at zip.com.au> wrote:
| >   If items(), keys(), values(), iteritems(), iterkeys(), and
| >   itervalues() are called with no intervening modifications to the
| >   dictionary, the lists will directly correspond. This allows the
| >   creation of (value, key) pairs using zip(): pairs = zip(d.values(),
| >   d.keys()).
| 
| I stand corrected. Thanks Cameron.

Oh, I was all ready to say what you said, but decided to check the docs
myself first:-)

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

I really don't like :-) symbols as well. I feel that if you can't see the pie
coming, you deserve whipped cream up your nose.
        - robd at cherry.cray.com (rob derrick)



More information about the Python-list mailing list