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 peter.otten
Recipients docs@python, peter.otten
Date 2011-11-30.17:42:01
SpamBayes Score 1.5724547e-05
Marked as misclassified No
Message-id <1322674949.97.0.856520026774.issue13510@psf.upfronthosting.co.za>
In-reply-to
Content
I've been looking at code on the tutor mailing list for some time, and

for line in file.readlines(): ...

is a common idiom there. I suppose this is because the readlines() method is easily discoverable while the proper way (iterate over the file object directly) is not.

A note added to the readlines() documentation might help:

"""
You don't need the readlines() method to loop over the lines of a file.
for line in file: process(line)
consumes less memory and is often faster.
"""
History
Date User Action Args
2011-11-30 17:42:30peter.ottensetrecipients: + peter.otten, docs@python
2011-11-30 17:42:29peter.ottensetmessageid: <1322674949.97.0.856520026774.issue13510@psf.upfronthosting.co.za>
2011-11-30 17:42:01peter.ottenlinkissue13510 messages
2011-11-30 17:42:01peter.ottencreate