dictionary comparison
Peter Schneider-Kamp
nowonder at nowonder.de
Thu Aug 10 14:30:00 EDT 2000
pzs at dcs.gla.ac.uk wrote:
>
> What's the best way of comparing a dictionary with another (possibly
> itself) without doing each comparison twice as
>
> for key1 in dict1.keys():
> for key2 in dict2.keys():
Far from being the best way, one obvious way would be to
loop over the concatenated keys-sequence of both dicts:
for key in dict1.keys()+dict2.keys():
try:
if dict1[key] != < > == ... dict2[key]:
do something
except KeyError:
...
Peter
--
Peter Schneider-Kamp ++47-7388-7331
Herman Krags veg 51-11 mailto:peter at schneider-kamp.de
N-7050 Trondheim http://schneider-kamp.de
More information about the Python-list
mailing list