Message148679
| 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:30 | peter.otten | set | recipients:
+ peter.otten, docs@python |
| 2011年11月30日 17:42:29 | peter.otten | set | messageid: <1322674949.97.0.856520026774.issue13510@psf.upfronthosting.co.za> |
| 2011年11月30日 17:42:01 | peter.otten | link | issue13510 messages |
| 2011年11月30日 17:42:01 | peter.otten | create |
|