Calling member functions?
David Dawkins
david_j_dawkins at spamless.hotmail.com
Thu Dec 13 06:20:52 EST 2001
Hi,
I can't quite get this right. How can I give an object instance and a method
as a callback for some other module/class to call at a later point?
class Handler:
def Callback(self):
print "Callback called"
class Notifier:
def __init__(self, object, method):
self.m_object = object
self.m_method = method
def notify(self):
## Now what??
self.m_method(self.m_object) ## naive attempt
h = Handler()
n = Notifier( h, h.Callback )
h.notify() # I want this to do h.Callback() in effect
Thanks
David Dawkins
--
david_j_dawkins x/AT/x hotmail.com
More information about the Python-list
mailing list