A beginning beginner's question about input, output and . . .

Terry Reedy tjreedy at udel.edu
Sat Jan 16 22:41:43 EST 2021


On 1/16/2021 9:17 PM, 2QdxY4RzWzUUiLuE at potatochowder.com wrote:

> A bare minimum skeleton might look something like this:
> 
>      with open(filename) as f:
>          for line in f.readlines():
>              handle_one_line(f)

f.readlines() reads the entire file into a list of lines (strings).  If 
you do not need that,
             for line in f:
is sufficient for iterating thru the file line by line.

-- 
Terry Jan Reedy



More information about the Python-list mailing list