So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is "N/n".
I'm already using an exception handler set with sys.excepthook, but I can't make it work with the confirm_exit, because it's going to quit in any case.. A possible solution would be to do a global "try/except KeyboardInterrupt", but since I already have an excepthook I wanted to use this. Any way to make it continue where it was running after the exception is handled? def confirm_exit(): while True: q = raw_input("This will quit the program, are you sure? [y/N]") if q in ('y', 'Y'): sys.exit(0) elif q in ('n', 'N'): print("Continuing execution") # just go back to normal execution, is it possible?? break def _exception_handler(etype, value, tb): if etype == KeyboardInterrupt: confirm_exit() else: sys.exit(1) def set_exception_handler(): sys.excepthook = _exception_handler -- http://mail.python.org/mailman/listinfo/python-list