[Tutor] keyboard interrupt

Jerry Hill malaclypse2 at gmail.com
Thu May 23 15:38:46 CEST 2013


On Wed, May 22, 2013 at 9:25 PM, Dave Angel <davea at davea.name> wrote:

> On 05/22/2013 04:11 PM, Jerry Hill wrote:
>
>> The KeyboardInterrupt ​exception is raised when someone presses Ctrl-C.
>>  If
>> you catch it, and ignore it (which is what your code above is doing), then
>> pressing Ctrl-C doesn't do anything.  If you just take out the try/except,
>> then you can hit Ctrl-C and interrupt your program as normal.
>>
>>
> What do you mean "doesn't do anything" ?  It certainly terminates the
> loop, which was the intent.  Provided of course that something else isn't
> trapping the Ctrl-C first.
>

​You're quite right.  I mis-read the original code as having the try/except
inside the loop.  ​The way Jim wrote it was correct.

-- 
Jerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130523/fc765d10/attachment.html>


More information about the Tutor mailing list