python ctrl+c

#!/usr/bin/env python
import signal
import sys
import os
def signal_handler(signal, frame):
print('You pressed Ctrl+C!')
# signal.signal(signal.SIGINT, signal_handler)
print('Press Ctrl+C')
# os.system('pause')
class SIGINT_handler():
def __init__(self):
self.SIGINT = False
def signal_handler(self, signal, frame):
print('You pressed Ctrl+C!')
self.SIGINT = True
handler = SIGINT_handler()
signal.signal(signal.SIGINT, handler.signal_handler)
os.system('pause')