[Tutor] exception about "ctrl+c"

daedae11 daedae11 at 126.com
Mon Jan 9 13:24:06 CET 2012


I want to catch the "ctrl+c" exception. My program is as following. But when I run my script and press "ctrl"+"c", the  program output nothing. I don't know where did I go wrong. Please help me. Thank you!

def safe_input(prompting):
    try:
        return raw_input(prompting);
    except KeyboardInterrupt, error:
        print error;
        return None;

def main():
    a = safe_input("input any thing!\n");
    print a;
    

if __name__ == '__main__':
    main();




daedae11
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120109/42ab6c1a/attachment.html>


More information about the Tutor mailing list