[Tutor] raw_input()

Benno Lang transmogribenno at gmail.com
Tue Mar 16 00:19:24 CET 2010


On 16 March 2010 08:04, kumar s <ps_python at yahoo.com> wrote:
> %cat mybigfile.rod | python x1.py
> Traceback (most recent call last):
>  File "x1.py", line 2, in <module>
>    second = raw_input()
> EOFError: EOF when reading a line
>
> How to notify that at EOF break and suppress exception.

try:
    second = raw_input()
except EOFError:
    # handle error in some way

I would probably supply the file name as an argument rather than
piping into stdin (or allow both methods), but that's up to you.

HTH,
benno


More information about the Tutor mailing list