Finding items not in 2 lists/dictionaries
Terry Reedy
tjreedy at udel.edu
Fri May 2 02:32:37 EDT 2003
"Robin Siebler" <robin.siebler at palmsource.com> wrote in message
news:95c29a5e.0305011933.289d71ca at posting.google.com...
> On page 15 of the Python Cookbook, it shows how to find all of the
> common items in 2 dictionaries. How would I find all of the items
> that are *not* in both dictionaries (or lists)?
More practical than previous reply (untested, it too late here):
out = dict(dict1)
for k,v in dict2:
if k in out:
del out[k]
else:
out[k] = v
Terrry J. Reedy
More information about the Python-list
mailing list