summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-03-20 18:36:00 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-03-20 18:36:00 (GMT)
commitcacbdf6229fb8f3769c0cc5a9bac78d86ca51657 (patch)
tree2934136375e4d67f36efbb4e7ccb2f291a50a8f3 /Lib
parentfbb556df15d66ced932619d61fb07ce9f9b34c0d (diff)
downloadcpython-cacbdf6229fb8f3769c0cc5a9bac78d86ca51657.zip
cpython-cacbdf6229fb8f3769c0cc5a9bac78d86ca51657.tar.gz
cpython-cacbdf6229fb8f3769c0cc5a9bac78d86ca51657.tar.bz2
Make GzipFile an iterator. Closes bug #532621.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/gzip.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 74c0d26..9e9f5d4 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -351,6 +351,16 @@ class GzipFile:
for line in L:
self.write(line)
+ def __iter__(self):
+ return self
+
+ def next(self):
+ line = self.readline()
+ if line:
+ return line
+ else:
+ raise StopIteration
+
def _test():
# Act like gzip; with -d, act like gunzip.