Catching control-C

Chris Rebert clp2 at rebertia.com
Mon Jul 6 17:44:20 EDT 2009


On Mon, Jul 6, 2009 at 2:37 PM, Michael Mossey<michaelmossey at gmail.com> wrote:
> What is required in a python program to make sure it catches a control-
> c on the command-line? Do some i/o? The OS here is Linux.

try:
    #code that reads input
except KeyboardInterrupt:
    #Ctrl-C was pressed

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-list mailing list