Getting the difference (delta) between two lists of dictionaries
I have the following Python data structures: data1 = [{'name': u'String 1'}, {'name': u'String 2'}] data2 = [{'name': u'String 1'}, {'name': u'String 2'}, {'name': u'String 3'}] I'm looking for the best way to get the delta between the two lists. Is there anything in Python that's as convenient as the JavaScript Underscore.js (_.difference) library? Use itertools.filterfalse : import itertools r = list(itertools.filterfalse(lambda x: x in data1, data2)) + list(itertools.filterfalse(lambda x: x in data2, data1)) assert r == [{'name': 'String 3'}] How about this: >>> [x for x in data2 if x not