Combine two dictionaries into a list of 3-tuples
Jeff Epler
jepler at unpythonic.net
Wed Nov 10 16:13:00 EST 2004
How about
[(k, v, two[v]) for k, v in one.items()]
or
[(k, v, two[v]) for k, v in one.items() if k in two]
or
[(k, v, two.get(v, None)) for k, v in one.items()]
depending on what you want to do when a key doesn't exist in "two"
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041110/0c547d50/attachment.sig>
More information about the Python-list
mailing list