|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
EOFError
Here's my program
Code:
short_factor = 1
long_factor = 2
rotat_factor = 3
try:
type = raw_input ("Enter type of motor: (S/L/R)" )
except EOFError:
print ('no input')
When I run it, I always got 'exceptions.EOFError' in the interactive window but it doesn't print 'no input', even though I did enter something. Any idea what's wrong? Thanks. Last edited by netytan : June 2nd, 2004 at 08:05 AM. Reason: Added Code tags |
|
#2
|
||||
|
||||
|
hm I just tried your program and i didnt get any error
Code:
short_factor = 1
long_factor = 2
rotat_factor = 3
try:
type = raw_input ("Enter type of motor: (S/L/R)" )
print type
except EOFError:
print ('no input')
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#3
|
|||
|
|||
|
u are absolutely right. I didn't something else wrong in other part of my program. But now the thing is I don't get the the program to print 'no input' even if I enter nothing to the prompt.
I'm wondering if that is the right way to handle the EOFError exception. Thanks. |
|
#4
|
|||
|
|||
|
Someone hitting enter during a raw_input() shouldn't raise an EOFError, it'd simply return "".
|
|
#5
|
||||
|
||||
|
Quote:
If you want the program to output ( no input ) then you need to add an if statement for that.. should work for ya |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > EOFError |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|