I find myself needing to calculate the difference between two Counters or multisets or bags.
I want those items that are unique to each bag. I know how to calculate it: >>> b = Counter(a=1, b=2) >>> c = Counter(a=3, b=1) >>> diff = (b - c) + (c - b) >>> (b - c) Counter({'b': 1}) >>> (c - b) Counter({'a': 2}) >>> diff Counter({'a': 2, 'b': 1}) But thought why doesn't this operation appear already as a method of the class? - Paddy. -- http://mail.python.org/mailman/listinfo/python-list