IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Look at the threading module in the library
...which has garden-variety thread support (semaphores, queues, events, rlocks, etc.). You should be able to find something for your needs. I haven't used 'raise event'--is that just a glorified callback?
I was one of the original authors of VB, and *I* wouldn't use VB for a text
processing program. :-)
Michael Geary, on comp.lang.python
New Re: Look at the threading module in the library
I haven't used 'raise event'--is that just a glorified callback?


Something like that. Quoting from the C# language specification, 1.7.5 Events:

An event is a member that enables an object or class to provide notifications. A class defines an event by providing an event declaration, which resembles a field declaration, though with an added event keyword, and an optional set of event accessors. The type of this declaration must be a delegate type.

An instance of a delegate type encapsulates one or more callable entities. For instance methods, a callable entity consists of an instance and a method on that instance. For static methods, a callable entity consists of just a method. Given a delegate instance and an appropriate set of arguments, one can invoke all of that delegate instance\ufffds methods with that set of arguments.


Just was wondering if I saw the way it's supposed to be done, or if I was missing it. In Python, it looks like you add a function to the list of functions for that event. When the "event" triggers, you walk through the list of functions, and call them.
I have a red sign on my door. It says "If this sign is blue, you're going too fast."
New Python idiom
Given that functions are objects in Python, you can "register" both the instance and its method in one operation:

>>> class Thing(object):
... \tdef aMethod(self, aParam):
... \t\tself.Value = aParam * 3
... \t\t
>>> some = Thing()
>>> some.aMethod
<bound method Thing.aMethod of <__main__.Thing object at 0x0128CE90>>
>>> f = some.aMethod
>>> f(4)
>>> print some.Value
12

In this example, f gets bound to the method for the "some" instance.
I was one of the original authors of VB, and *I* wouldn't use VB for a text
processing program. :-)
Michael Geary, on comp.lang.python
     Python question: Events - (inthane-chan) - (3)
         Look at the threading module in the library - (FuManChu) - (2)
             Re: Look at the threading module in the library - (inthane-chan) - (1)
                 Python idiom - (FuManChu)

Like a cat on a hot tin roof.
38 ms