Why doesn't code like the following catch CTRL-C?
MAXVAL = 10000
STEP_INTERVAL = 10
for i in range(1, MAXVAL, STEP_INTERVAL):
try:
print str(i)
except KeyboardInterrupt:
break
print "done"
My expectation is -- if CTRL-C is pressed while program is running, KeyboardInterrupt
is supposed to leave the loop. It does not.
Any help on what I'm doing wrong?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With