Signal question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Pellew

    Signal question

    Hi;

    I am on WinXPPro and want to catch the keyboard interrupt signal.
    Will Python 2.3.3 signal handler catch it?

    Cannot find this in the Pyt docs,
    Mind nor can I find `inc += 1` statement that I find a poor substitute for `i++`!!

    Pointers/Advice Pls.

    Regards
    Ian
  • Miki Tebeka

    #2
    Re: Signal question

    Hello Ian,
    [color=blue]
    > I am on WinXPPro and want to catch the keyboard interrupt signal.
    > Will Python 2.3.3 signal handler catch it?[/color]
    from signal import SIGINT, signal
    from time import sleep

    def sigint_handler( signum, frame):
    print "OUCH"

    signal(SIGINT, sigint_handler)

    while 1:
    sleep(1)
    print "BEEP"
    [color=blue]
    > Cannot find this in the Pyt docs,http://www.python.org/doc/current/li...le-signal.html[/color]
    [color=blue]
    > Mind nor can I find `inc += 1` statement that I find a poor substitute for `i++`!![/color]
    Python tries to keep the language as compact as possible. There is no
    intension to make it look like C/C++. I don't find these 2 extra chars
    annoying.

    HTH.
    Miki

    Comment

    Working...