[docs] [issue13510] Clarify that readlines() is not needed to iterate over a file
report at bugs.python.org
Wed Nov 30 18:42:30 CET 2011
New submission from Peter Otten <__peter__ at web.de>:
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.
assignee: docs at python
nosy: docs at python, potten
title: Clarify that readlines() is not needed to iterate over a file
type: feature request
Python tracker <report at bugs.python.org>
More information about the docs