summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-30 00:08:31 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-01-30 00:08:31 (GMT)
commit7d518f418b8bb7f155c8e695adbc5b69ac0ed0fd (patch)
tree6e930fe9c1e73a4a34d97211e30973edc482b4ce /Lib
parentabf3fcf39fb3bff4d347296a083a4c62d515dacd (diff)
downloadcpython-7d518f418b8bb7f155c8e695adbc5b69ac0ed0fd.zip
cpython-7d518f418b8bb7f155c8e695adbc5b69ac0ed0fd.tar.gz
cpython-7d518f418b8bb7f155c8e695adbc5b69ac0ed0fd.tar.bz2
MutableSets support a remove() method.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_abcoll.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py
index 3a84b96..e1e6510 100644
--- a/Lib/_abcoll.py
+++ b/Lib/_abcoll.py
@@ -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)