This is probably a question about the noob. For any dictionary 'd' in python, this is always True:
dict( zip( d.keys(), d.values() ) ) == d
Are keys and values returned in the same order?
Yes, this is always the case. Python is guaranteed if there are no intermediate modifications to ditionary.
Related specification: http://docs.python.org/library/stdtypes.html#dict.items
This is better, as a rule, because it protects against a dict coming out of synchronization and uses a little extra memory:
dict((k,v) for k,v in d.iteritems())
, , "". :
items(), keys(), values(), iteritems(), iterkeys() itervalues() , .
items()
keys()
values()
iteritems()
iterkeys()
itervalues()
, dict( zip( d.keys(), d.values() ) ) == d True , . , d, d.keys(), d.values(), dict(...). , , .
d
d.keys()
d.values()
dict(...)
, : -)
, d.items: http://docs.python.org/library/stdtypes.html#dict.items
. d.items() , d.keys() d.values().
d.items()