[Tutor] raw_input()

kumar s ps_python at yahoo.com
Tue Mar 16 00:22:55 CET 2010


thanks Benno. 

supplying 3.6 GB file is over-kill for the script.  This is the reason I chose to input lines on fly. 

thanks
Kumar





----- Original Message ----
From: Benno Lang <transmogribenno at gmail.com>
To: kumar s <ps_python at yahoo.com>
Cc: tutor at python.org
Sent: Mon, March 15, 2010 7:19:24 PM
Subject: Re: [Tutor] raw_input()

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