On May 16, 4:47 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
> Python's lack of an EOF character is giving me a hard time.
>
> I've tried:
>
> -----
> s = f.readline()
> while s:
> .
> .
> s = f.readline()
> --------
>
> and
>
> -------
> s = f.readline()
> while s != ''
> .
> .
> s = f.readline()
> -------
>
> In both cases, the loop ends as soon it encounters an empty line in
> the file, i.e.
>
> xxxxxxxxxx
> xxxxxxxxxxx
> xxxxxxx
>                           < - - -  loop end here
> xxxxxxxxxxxxxx
> xxxxxxxxxx
> x
>                            < ---- loop should end here

Use a "for s in f" loop instead.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to