Try the following:
other_dictionary = defaultdict(list, ((k, v) for k, v in other_dictionary.iteritems() if k not in some_dictionary))
Note that defaultdict must accept as the first argument to determine the default value. There was no list argument in your code.
Other than that, your algorithm was essentially correct, but it can be written more concisely using iteritems() , as shown above.
source share