This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nickjacobson
Recipients
Date 2004-09-28.22:42:45
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
(A.M. Kuchling told me to post this bug report.)

In section 2.3.8, "File Objects", of the Python Library 
Reference, the following section is given for file.next():

<<
In order to make a for loop the most efficient way of 
looping over the lines of a file (a very common 
operation), the next() method uses a hidden read-ahead 
buffer. As a consequence of using a read-ahead buffer, 
combining next() with other file methods (like readline()) 
does not work right.
>>

This information is necessary for anyone who mixes "for 
line in file:" with read()/tell()/etc.  However, in the 
statement "for line in file:", next() is called implicitly, and 
therefore it may not occur to the programmer to find the 
information there.

Therefore the documentation should be reorganized.
One solution is to have the read()/tell()/etc. methods 
refer to the above section.  i.e. "Don't use this method 
with next() or 'for line in file:'; see next()."

A second solution is to move the above section to 
before the methods section (i.e. after the second 
paragraph after the 2.3.8 header), and to mention 'for 
line in file:'.
i.e. "As a consequence of using a read-ahead buffer, 
combining next() or 'for line in file:' with other file 
methods (like readline()) does not work right."

(Also, saying "with other file methods (like readline())" is 
too vague.  IMHO it should specify which ones not to 
use.  That's debatable though.)
History
Date User Action Args
2007-08-23 14:26:29adminlinkissue1036626 messages
2007-08-23 14:26:29admincreate