On 07/15/2011 04:01 AM, bruno.desthuilli...@gmail.com wrote:
On Jul 14, 9:46 pm, Billy Mays<no...@nohow.com> wrote:
I noticed that if a file is being continuously written to, the file
generator does not notice it:
def getLines(f):
lines = []
for line in f:
lines.append(line)
return lines
what's wrong with file.readlines() ?
Using that will read the entire file into memory which may not be
possible. In the library reference, it mentions that using the
generator (which calls file.next()) uses a read ahead buffer to
efficiently loop over the file. If I call .readline() myself, I forfeit
that performance gain.
I was thinking that a convenient solution to this problem would be to
introduce a new Exception call PauseIteration, which would signal to the
caller that there is no more data for now, but not to close down the
generator entirely.
--
Bill
--
http://mail.python.org/mailman/listinfo/python-list