Keys To The Kingdom
aleaxit at yahoo.com
Tue Jul 10 11:37:07 CEST 2001
"Tim Daneliuk" <tundra at tundraware.com> wrote in message
news:3B4AC204.80941297 at tundraware.com...
> Tim Hammerquist wrote:
> > This works for me:
> > try:
> > input = raw_input()
> > except KeyboardInterrupt:
> > # handle Ctrl-C
> > The only difference I see is the capital 'B' you have in
> > 'KeyboardInterrupt'. Change it to lowercase and see what happens.
> (Whoops, I spelled it wrong here, but correctly in my program.)
> This code fragment works fine under Unix (FreeBSD 4.3) but not under
> Windows 2000. Is this a known bug or is there some magic I'm missing?
It seems to me (trying under NT4) that raw_input() is generating
an EOFError on Ctrl-C (or Ctrl-Break) rather than the exception
you (reasonably expect), i.e. KeyboardInterrupt. Maybe try an
except (KeyboardInterrupt, EOFError):
to catch both...? Of course, on Unix EOFError would happen if
the user hit Ctrl-D rather than Ctrl-C, and on Windows also on
Ctrl-Z followed by a return, but...
More information about the Python-list