From: Raymond Hettinger Date: Wed, 30 Jan 2008 00:08:31 +0000 (+0000) Subject: MutableSets support a remove() method. X-Git-Tag: v2.6a1~342 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d518f418b8bb7f155c8e695adbc5b69ac0ed0fd;p=python MutableSets support a remove() method. --- diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index 3a84b965b4..e1e65106ce 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)