Syntax for extracting multiple items from a dictionary

shark no at spam.none
Tue Nov 30 08:22:50 EST 2004


row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken", "state" :
"Alaska"}
cols = ("city", "state")

Is there a best-practices way to ask for an object containing only the keys
named in cols out of row? In other words, to get this:
{"city" : "Hoboken", "state" : "Alaska"}

Thanks,

shark





More information about the Python-list mailing list