diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2002-03-20 18:36:00 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2002-03-20 18:36:00 (GMT) |
commit | cacbdf6229fb8f3769c0cc5a9bac78d86ca51657 (patch) | |
tree | 2934136375e4d67f36efbb4e7ccb2f291a50a8f3 /Lib/gzip.py | |
parent | fbb556df15d66ced932619d61fb07ce9f9b34c0d (diff) | |
download | cpython-cacbdf6229fb8f3769c0cc5a9bac78d86ca51657.zip cpython-cacbdf6229fb8f3769c0cc5a9bac78d86ca51657.tar.gz cpython-cacbdf6229fb8f3769c0cc5a9bac78d86ca51657.tar.bz2 |
Make GzipFile an iterator. Closes bug #532621.
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r-- | Lib/gzip.py | 10 |
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. |