for key, value in dict.<func>() - how to get? (which func)

dmitrey dmitrey.kroshko at scipy.org
Tue Aug 11 21:15:13 CEST 2009


hi all,
which method should I use to get iterator over (key, value) pairs for
Python dict, Python v 2.6 and above?

Of course I could use

for key in myDict.keys():
    value = myDict.values()
    # do something with the pair key, value

but searching each time for the value take some cputime that is
serious for the task involved

IIRC in python 2.5 I have something like keyvalues(), but I don't see
something like that in current dir(myDict).

Thank you in advance, D.



More information about the Python-list mailing list