From 7d518f418b8bb7f155c8e695adbc5b69ac0ed0fd Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 30 Jan 2008 00:08:31 +0000 Subject: [PATCH] MutableSets support a remove() method. --- Lib/_abcoll.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index 3a84b965b48..e1e65106cea 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)