]> granicus.if.org Git - python/commitdiff
Issue #11388: Added a clear() method to MutableSequence
authorEli Bendersky <eliben@gmail.com>
Fri, 4 Mar 2011 05:34:58 +0000 (05:34 +0000)
committerEli Bendersky <eliben@gmail.com>
Fri, 4 Mar 2011 05:34:58 +0000 (05:34 +0000)
Lib/collections/abc.py
Misc/NEWS

index 6e908bdce973fde7ed675df81658bd66b42e20d7..c80c7ddd4430300799011d7d7c60868dee19bd4a 100644 (file)
@@ -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):
index 876afdd08ef38e986f0e58e80db40efae8c3347b..6b484f727c90f4437b37917290f878b33a2014a0 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -140,6 +140,8 @@ Library
 - Issue #10276: Fix the results of zlib.crc32() and zlib.adler32() on buffers
   larger than 4GB.  Patch by Nadeem Vawda.
 
+- Issue #11388: Added a clear() method to MutableSequence
+
 Build
 -----