Propagating function calls
James Mills
prologic at shortcircuit.net.au
Tue Feb 10 20:24:49 EST 2009
On Wed, Feb 11, 2009 at 11:02 AM, Noam Aigerman <noama at answers.com> wrote:
> Suppose I have a python object X, which holds inside it a python object Y.
> How can I propagate each function call to X so the same function call in Y
> will be called, i.e:
>
> X.doThatFunkyFunk()
>
> Would cause
>
> Y.doThatFunkyFunk()
Noam, using circuits [1] you could do this:
----
from circuits import Event, Component, Manager
class X(Component):
def doThatFunkyFunk(self):
...
class Y(Component):
def doThatFunkyFunk(self):
...
manager = Manager()
manager += X()
manager += Y()
manager.send(Event(), "doThatFunkyFunk")
----
cheers
James
[1] http://pypi.python.org/pypi/circuits/
More information about the Python-list
mailing list