On Fri, Oct 26, 2012 at 2:31 AM, Hans Mulder <han...@xs4all.nl> wrote: > This seems to work; I'm not sure how robust it is: > > import signal > > def handler(signum, frame): > while True: > q = raw_input("This will quit the program, are you sure? [y/N]") > if q[:1] in "yY": > raise KeyboardInterrupt > elif q[:1] in "nN": > print("Continuing execution") > # just go back to normal execution > return > > signal.signal(signal.SIGINT, handler) >
Yes, that's what I was talking about. You do have to be fairly careful what you do (for instance, what should happen if the user hits Ctrl-C during handler()? Default is that it'll raise KeyboardInterrupt unconditionally), but you have perfect flexibility. ChrisA -- http://mail.python.org/mailman/listinfo/python-list