Iterating over readlines() and map()

W. Martin Borgert debacle at
Thu Mar 26 01:27:14 CET 2009

(Resend, because of funny error message:
> Your mail to 'Python-list' with the subject
>     Iterating over readlines() and map()
> Is being held until the list moderator can review it for approval.
Whatever this means.)


if I understand correctly, this code would not read the complete file
into the memory:

for line in myfile.readlines():

Is this also true for this code?

for line in map(myfunction, myfile.readlines()):

Or would use of map() mean, that the complete "myfile" is read into
the RAM? In this case, I would change it to:

for line in myfile.readlines():
    line = myfunction(line)


More information about the Python-list mailing list