On 2010-04-05 10:08:51 -0700, John Nagle said:
    Yes.  Functions with persistent state are generally a bad idea.

    Unfortunately, the "signal" module requires a callback parameter
which is a plain function.  So you have to send it a function,
closure, or lambda.  Here, it's being sent a closure - "handler"
bound to the state that existed when "signal.signal" was called.

Uhh, what?

class A:
...     def handle(self, foo, bar):
...             print "Okay"
...
a = A()
signal.signal(signal.SIGALRM, a.handle)
0
Okay

Where after that call to signal.signal, I did kill -ALRM and such in another process.

When Python says 'a function', it doesn't mean a -plain- function. A method's a function too. Arguably, really, any callable is almost always (as in I can't think of anywhere it doesn't) sufficient to be Functiony enough to work.

--
--S

... p.s: change the ".invalid" to ".com" in email address to reply privately.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to