]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add readlines() to _Subfile class. Not clear who would need it, but
authorGuido van Rossum <guido@python.org>
Wed, 24 Mar 1999 16:20:45 +0000 (16:20 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 24 Mar 1999 16:20:45 +0000 (16:20 +0000)
Chris Lawrence sent me a broken version; this one is a tad simpler and
more conforming to the standard.

Lib/mailbox.py

index f965b0fd86725a98b59233d396ed68e11c270f74..3c758ff6e12d12e177e06ab2145a1b6a9e5974e3 100755 (executable)
@@ -66,6 +66,19 @@ class _Subfile:
                self.pos = self.fp.tell()
                return data
 
+        def readlines(self, sizehint = -1):
+               lines = []
+               while 1:
+                       line = self.readline()
+                       if not line:
+                               break
+                       lines.append(line)
+                       if sizehint >= 0:
+                               sizehint = sizehint - len(line)
+                               if sizehint <= 0:
+                                       break
+               return lines
+
        def tell(self):
                return self.pos - self.start