[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-15 Thread Ezio Melotti
Ezio Melotti added the comment: Fixed, thanks for the patch! I also realized I missed Terry suggestion about file.readlines() == list(file), so I added that too. -- assignee: docs@python -> ezio.melotti resolution: -> fixed stage: needs patch -> committed/rejected status: open -> close

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-15 Thread Roundup Robot
Roundup Robot added the comment: New changeset 1e8be05a4039 by Ezio Melotti in branch '3.3': #13510: clarify that f.readlines() is note necessary to iterate over a file. Patch by Dan Riti. http://hg.python.org/cpython/rev/1e8be05a4039 New changeset 7f4325dc4256 by Ezio Melotti in branch 'defau

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-15 Thread Dan Riti
Dan Riti added the comment: Agreed Ezio, I've updated the patch to include the change to Doc/library/io.rst:readlines. -- Added file: http://bugs.python.org/file29868/demote-readlines-v3.patch ___ Python tracker _

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-14 Thread Ezio Melotti
Ezio Melotti added the comment: Patch LGTM. I think it would also be better to say something like "Note that it's already possible to iterate on file objects using ``for line in file: ...`` without calling file.readlines()." in Doc/library/io.rst:readlines, as suggested in msg148703. ---

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-14 Thread Dan Riti
Dan Riti added the comment: Added a new version of the patch to incorporate Ezio's comment! -- Added file: http://bugs.python.org/file29859/demote-readlines-v2.patch ___ Python tracker _

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-14 Thread Terry J. Reedy
Terry J. Reedy added the comment: I agree with removing .readlines section. If .readlines did not exist, I do not think we would add it now. -- ___ Python tracker ___ __

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I would actually remove the whole section about readlines() or > possibly just mention it briefly (something like "If you want to read > all the lines of a file in a list you can also use f.readlines().") > The sizehint arg is rarely used, so I don't see the po

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-14 Thread Ezio Melotti
Ezio Melotti added the comment: I would actually remove the whole section about readlines() or possibly just mention it briefly (something like "If you want to read all the lines of a file in a list you can also use f.readlines().") The sizehint arg is rarely used, so I don't see the point of g

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: In 3.x I think we'll want to drop the following sentence: "Since the two approaches manage line buffering differently, they should not be mixed". But it can wait for another issue. -- nosy: +pitrou ___ Python tracke

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-04-13 Thread Dan Riti
Dan Riti added the comment: After reading the comments, I generated a patch that does the following: - Reorganize to present `for line in f:` as the first approach for reading lines. I refrained from saying it's the *preferred* approach, however I can add that if desired. - Reorganize to prese

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-03-28 Thread Kushal Das
Kushal Das added the comment: Working on a patch for this. -- nosy: +kushaldas ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-03-28 Thread Ezio Melotti
Changes by Ezio Melotti : -- versions: -Python 3.2 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue13510] Clarify that readlines() is not needed to iterate over a file

2013-03-27 Thread Ashwini Chaudhary
Changes by Ashwini Chaudhary : -- nosy: +montysinngh ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue13510] Clarify that readlines() is not needed to iterate over a file

2012-10-26 Thread Mike Hoy
Changes by Mike Hoy : -- nosy: +mikehoy ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/

[issue13510] Clarify that readlines() is not needed to iterate over a file

2012-10-25 Thread Ezio Melotti
Changes by Ezio Melotti : -- keywords: +easy versions: +Python 3.4 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscrib

[issue13510] Clarify that readlines() is not needed to iterate over a file

2012-10-25 Thread Éric Araujo
Éric Araujo added the comment: readlines might be discouraged; readline has its use cases (two days ago I used it to get one line to pass to csv.Sniffer.sniff), but next(file) works too, so it could be de-emphasized. There may be a difference with respect to the trailing newline however; I do

[issue13510] Clarify that readlines() is not needed to iterate over a file

2012-10-24 Thread Chris Rebert
Chris Rebert added the comment: file.readlines() (and perhaps dare I say even file.readline()) should not even be mentioned in the tutorial, IMO. It is difficult to imagine a use case where just iterating over the file object isn't superior. I cannot remember the last time that I have used eit

[issue13510] Clarify that readlines() is not needed to iterate over a file

2011-11-30 Thread Ezio Melotti
Ezio Melotti added the comment: FWIW I've seen several persons using "for line in file.readlines(): ..." or even "while 1: line = file.readline()". IMHO it's a good idea to document that "without sizehint, it's equivalent to list(file)" and that "for line in file: ..." can be used directly.

[issue13510] Clarify that readlines() is not needed to iterate over a file

2011-11-30 Thread Meador Inge
Meador Inge added the comment: I am skeptical that such a note will help. The iterator behavior is clearly pointed out in the Python Tutorial [1] and in the IOBase documentation [2]. I suspect this bad code pattern is just being copied and pasted from other sources without folks ever even l

[issue13510] Clarify that readlines() is not needed to iterate over a file

2011-11-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: This current line is "Read and return a list of lines from the stream. hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint." I would like to see added "

[issue13510] Clarify that readlines() is not needed to iterate over a file

2011-11-30 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +eric.araujo, ezio.melotti stage: -> needs patch versions: +Python 2.7, Python 3.2, Python 3.3 ___ Python tracker ___

[issue13510] Clarify that readlines() is not needed to iterate over a file

2011-11-30 Thread Peter Otten
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 f