summaryrefslogtreecommitdiffstats
path: root/Lib/collections/abc.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2011-03-04 05:34:58 (GMT)
committerEli Bendersky <eliben@gmail.com>2011-03-04 05:34:58 (GMT)
commit9479d1ade84d7a386a107989b699fb90b73cfa15 (patch)
tree28f601ede8422262fdae0696a36790ceea3474f7 /Lib/collections/abc.py
parent1bc4f193d8419405e9b34f5e8dcbeb2ee5a15fc9 (diff)
downloadcpython-9479d1ade84d7a386a107989b699fb90b73cfa15.zip
cpython-9479d1ade84d7a386a107989b699fb90b73cfa15.tar.gz
cpython-9479d1ade84d7a386a107989b699fb90b73cfa15.tar.bz2
Issue #11388: Added a clear() method to MutableSequence
Diffstat (limited to 'Lib/collections/abc.py')
-rw-r--r--Lib/collections/abc.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/collections/abc.py b/Lib/collections/abc.py
index 6e908bd..c80c7dd 100644
--- a/Lib/collections/abc.py
+++ b/Lib/collections/abc.py
@@ -596,6 +596,13 @@ class MutableSequence(Sequence):
def append(self, value):
self.insert(len(self), value)
+ def clear(self):
+ try:
+ while True:
+ self.pop()
+ except IndexError:
+ pass
+
def reverse(self):
n = len(self)
for i in range(n//2):