Thread: EOFError

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    56
    Rep Power
    11

    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. #2
  3. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    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')
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    56
    Rep Power
    11
    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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Someone hitting enter during a raw_input() shouldn't raise an EOFError, it'd simply return "".
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  8. #5
  9. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    Originally Posted by oli
    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.
    If you want the program to output ( no input ) then you need to add an if statement for that.. should work for ya

IMN logo majestic logo threadwatch logo seochat tools logo