]> granicus.if.org Git - python/commitdiff
MutableSets support a remove() method.
authorRaymond Hettinger <python@rcn.com>
Wed, 30 Jan 2008 00:08:31 +0000 (00:08 +0000)
committerRaymond Hettinger <python@rcn.com>
Wed, 30 Jan 2008 00:08:31 +0000 (00:08 +0000)
Lib/_abcoll.py

index 3a84b965b4808ab752e106446b7e54a22e58ead6..e1e65106ceaab86857492d7453bf3addacf8c439 100644 (file)
@@ -250,6 +250,12 @@ class MutableSet(Set):
         """Return True if it was deleted, False if not there."""
         raise NotImplementedError
 
+    def remove(self, value):
+        """Remove an element. If not a member, raise a KeyError."""
+        if value not in self:
+            raise KeyError(value)
+        self.discard(value)
+
     def pop(self):
         """Return the popped value.  Raise KeyError if empty."""
         it = iter(self)