From 95efd905a05b1f84acf9c12d095c04e33d980738 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 21 Jan 2009 20:31:50 +0000 Subject: Simplify explanation of multiset operations by removing restrictions on negative inputs. --- Lib/collections.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/collections.py') diff --git a/Lib/collections.py b/Lib/collections.py index a853076cb2..eb13f4d2fd 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -312,8 +312,8 @@ class Counter(dict): if not isinstance(other, Counter): return NotImplemented result = Counter() - for elem, count in self.iteritems(): - newcount = count - other[elem] + for elem in set(self) | set(other): + newcount = self[elem] - other[elem] if newcount > 0: result[elem] = newcount return result -- cgit v1.2.1