ctrl+c in python

This is what happens when a c++ programmer starts coding in python 😛
Just as a reference, to kill a script using ctrl+c – add the following code in your script

import signal

def handler(signum, frame):
    print 'Exiting!!!'
    sys.exit()

signal.signal(signal.SIGINT, handler)

Leave a Reply