Warning about "for line in file:"

Neil Schemenauer nas at python.ca
Wed Feb 20 17:33:07 EST 2002


Jason Orendorff wrote:
> I agree!  This could be improved by having file.__iter__()
> always return the same object.  But that doesn't solve the problem
> in full.

Perhaps the buffer should be attached to the file object itself instead
of to the iterator.  read() and readline() could then be changed to use
the buffer if it exists.

  Neil




More information about the Python-list mailing list