Signal question

Miki Tebeka miki.tebeka at zoran.com
Thu Feb 26 11:58:54 EST 2004


Hello Ian,

> I am on WinXPPro and want to catch the keyboard interrupt signal.
> Will Python 2.3.3 signal handler catch it?
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"

> Cannot find this in the Pyt docs,http://www.python.org/doc/current/lib/module-signal.html 

> Mind nor can I find `inc += 1` statement that I find a poor substitute for `i++`!!
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



More information about the Python-list mailing list