[Tutor] Exception not working as expected?
Alan Gauld
alan.gauld at yahoo.co.uk
Thu Feb 28 20:34:14 EST 2019
On 28/02/2019 21:03, Chip Wachob wrote:
> it does work properly in Linux. So I'm guessing I need to test for a
> different exception along with the KeyboardInterrupt??
Don't guess, test.
Write a single line script
raw_input('> ')
Run it in a console.
Hit Ctrl-C while it waits for input.
See what the stack trace says is the exception
Edit your script
try:
raw_input('> ')
except <whatever e3xception you saw previously>:
print "I got it that time!"
run the new script.
Did it work? Hooray! Transfer to the main script.
If not come back here armed with tracebacks...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list