I can't for the life of me figure out how to set a callback in
Python. I have a class, which wraps another class. The second class
needs a callback assigned. I don't want to use globals for it.
Here's what I'd like to do:
class MyWrapper:
def get_login(self, username):
return self.user, self.pass
def __init__(self, user, pass):
self.user = user
self.pass = pass
self.client = Client("connect ion string")
self.client.cal lback_login = get_login
.... but obviously, the Client class, when it calls the callback,
doesn't pass a reference to the "self" object. How do I do this?
-- Chris
Python. I have a class, which wraps another class. The second class
needs a callback assigned. I don't want to use globals for it.
Here's what I'd like to do:
class MyWrapper:
def get_login(self, username):
return self.user, self.pass
def __init__(self, user, pass):
self.user = user
self.pass = pass
self.client = Client("connect ion string")
self.client.cal lback_login = get_login
.... but obviously, the Client class, when it calls the callback,
doesn't pass a reference to the "self" object. How do I do this?
-- Chris
Comment