I needed to compare 2 dictionaries to find a set of keys in one dictionary that was not in another.
I know Python object support:
set3=set1-set2
but I can not:
dict3=dict1-dict2
or
missingKeys=dict1.keys()-dict2.keys()
(I was a bit surprised at the last point, because in Java, keys are Set objects.) One solution:
missingKeys=set(dict1.keys())-set(dict2.keys())
Is there a better or more concise way to do this?
source share