diff options
author | Eli Bendersky <eliben@gmail.com> | 2011-03-04 05:34:58 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2011-03-04 05:34:58 (GMT) |
commit | 9479d1ade84d7a386a107989b699fb90b73cfa15 (patch) | |
tree | 28f601ede8422262fdae0696a36790ceea3474f7 /Lib/collections | |
parent | 1bc4f193d8419405e9b34f5e8dcbeb2ee5a15fc9 (diff) | |
download | cpython-9479d1ade84d7a386a107989b699fb90b73cfa15.zip cpython-9479d1ade84d7a386a107989b699fb90b73cfa15.tar.gz cpython-9479d1ade84d7a386a107989b699fb90b73cfa15.tar.bz2 |
Issue #11388: Added a clear() method to MutableSequence
Diffstat (limited to 'Lib/collections')
-rw-r--r-- | Lib/collections/abc.py | 7 |
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): |