summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-03-24 16:20:45 (GMT)
committerGuido van Rossum <guido@python.org>1999-03-24 16:20:45 (GMT)
commite256a0feed699a0bf9c22be0a0e0995632cfa4c4 (patch)
treeee607c48e2e387304ab91fff9b469c7f55ed1669 /Lib
parent9b8afdee44aaea0562d0400bc4a1b82d81debdce (diff)
downloadcpython-e256a0feed699a0bf9c22be0a0e0995632cfa4c4.zip
cpython-e256a0feed699a0bf9c22be0a0e0995632cfa4c4.tar.gz
cpython-e256a0feed699a0bf9c22be0a0e0995632cfa4c4.tar.bz2
Add readlines() to _Subfile class. Not clear who would need it, but
Chris Lawrence sent me a broken version; this one is a tad simpler and more conforming to the standard.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/mailbox.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index f965b0f..3c758ff 100755
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -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