mirror of
https://github.com/python/cpython.git
synced 2025-09-19 23:20:25 +00:00
Heh -- I checked in an old version of this, at a time I documented the
internal read() as being a generator but hadn't yet changed it into one.
This commit is contained in:
parent
21d7d4d5ca
commit
8d17a90b83
1 changed files with 1 additions and 3 deletions
|
@ -74,13 +74,11 @@ import sys
|
||||||
# (when whilematch is false), is lost, and fileiter will resume at the line
|
# (when whilematch is false), is lost, and fileiter will resume at the line
|
||||||
# following it.
|
# following it.
|
||||||
def read(fileiter, pat, whilematch):
|
def read(fileiter, pat, whilematch):
|
||||||
result = []
|
|
||||||
for line in fileiter:
|
for line in fileiter:
|
||||||
if bool(pat.match(line)) == whilematch:
|
if bool(pat.match(line)) == whilematch:
|
||||||
result.append(line)
|
yield line
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
return result
|
|
||||||
|
|
||||||
def combine(fname):
|
def combine(fname):
|
||||||
f = file(fname)
|
f = file(fname)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue