Storing a callback function as a class member

Nathan Huesken python at lonely-star.org
Wed Jul 7 17:48:11 EDT 2010


Hi,

I have a class, where I want to store a callback function as a member
to access later:

class CallbackClass:
    def setCallback(self,cb):
        self.cb = cb

    def callCallback(self, para):
        self.cb(para)

Doing so, I get the error:
callbackFunc() takes exactly 1 parameter (2 given)

self is given as parameter this way, is it not? How can this be done?

Thanks!
Nathan



More information about the Python-list mailing list