[2.5.1] Read each line from txt file, replace, and save?

Gilles nospam at nospam.com
Wed Sep 5 08:52:12 EDT 2012


On Sun, 02 Sep 2012 14:04:29 -0400, Terry Reedy <tjreedy at udel.edu>
wrote:
>If you process each line separately, there is no reason to read them all 
>at once. Use the file as an iterator directly. Since line is already a 
>string, there is no reason to copy it into a new string. Combining these 
>two changes with Mark's suggestion to use with and we have the following 
>simple code:

Thanks guys for the suggestion.



More information about the Python-list mailing list