mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Make GzipFile an iterator. Closes bug #532621.
This commit is contained in:
parent
fbb556df15
commit
cacbdf6229
1 changed files with 10 additions and 0 deletions
10
Lib/gzip.py
10
Lib/gzip.py
|
@ -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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue