[Tutor] use gzip with large files

Kent Johnson kent37 at tds.net
Tue Jul 19 22:52:52 CEST 2005


Hugo González Monteverde wrote:
> for a file-like object with a read method:
> 
> for line in file:
>      if not line:
>          break

The test
  if not line:
    break
is not needed with this form of looping; the loop will end automatically when it gets to the end of the file.

> 
> line will be "" for EOF, "\n" for an empty line.

No, you will not see the EOF in the loop, the loop will just terminate.

Kent



More information about the Tutor mailing list