FAQ

On 2009-03-26 01:41, Christian Heimes wrote:
No, you are wrong. file.readlines() reads the entire file into memory
and returns a list of strings. If you want to iterate over the lines of
a text file you can simply write:

for line in myfile:
dosomethingwith(line)

It won't work for a binary file, though.
Thanks for the information! (In my case it's always text and not
even large, so reading in memory is OK. I just was curios.)

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 5 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedMar 25, '09 at 8:16p
activeMar 26, '09 at 4:03a
posts5
users3
websitepython.org

People

Translate

site design / logo © 2023 Grokbase