Avoiding a SyntaxError when giving no input

Erno Kuusela erno-news at erno.iki.fi
Wed Jan 16 08:46:56 EST 2002


In article <d013da35.0201160502.4b9ea383 at posting.google.com>,
heiko.wolf at dlr.de (Heiko Wolf) writes:

| I tried it with exception handling, but that doesnt seem to work with
| SyntaxError.

sure it works:

>>> try:
...   x = input()
... except SyntaxError, what:
...   print 'bad:', what
... 

bad: unexpected EOF while parsing (line 0)
>>> 

  -- erno



More information about the Python-list mailing list