Make GzipFile an iterator. Closes bug #532621.

This commit is contained in:
Neil Schemenauer 2002-03-20 18:36:00 +00:00
parent fbb556df15
commit cacbdf6229
1 changed files with 10 additions and 0 deletions

View File

@ -351,6 +351,16 @@ class GzipFile:
for line in L: for line in L:
self.write(line) self.write(line)
def __iter__(self):
return self
def next(self):
line = self.readline()
if line:
return line
else:
raise StopIteration
def _test(): def _test():
# Act like gzip; with -d, act like gunzip. # Act like gzip; with -d, act like gunzip.