From: Neil Schemenauer Date: Wed, 20 Mar 2002 18:36:00 +0000 (+0000) Subject: Make GzipFile an iterator. Closes bug #532621. X-Git-Tag: v2.3c1~6430 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cacbdf6229fb8f3769c0cc5a9bac78d86ca51657;p=python Make GzipFile an iterator. Closes bug #532621. --- diff --git a/Lib/gzip.py b/Lib/gzip.py index 74c0d26a06..9e9f5d4b1f 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.