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

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to