New submission from Peter Otten <__pete...@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@python
components: Documentation
messages: 148679
nosy: docs@python, potten
priority: normal
severity: normal
status: open
title: Clarify that readlines() is not needed to iterate over a file
type: feature request

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13510>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to