From cacbdf6229fb8f3769c0cc5a9bac78d86ca51657 Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Wed, 20 Mar 2002 18:36:00 +0000 Subject: [PATCH] Make GzipFile an iterator. Closes bug #532621. --- Lib/gzip.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/gzip.py b/Lib/gzip.py index 74c0d26a065..9e9f5d4b1f7 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -351,6 +351,16 @@ def writelines(self, L): 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.