"水静流深" <[email protected]>:
> I want to call back a function which is the method of a class .
>
> def callback(self.do,x):
> return(self.do(x))
>
> That is what i want to write,when i input
>
> def callback(self.do,x):
>
> error message:
Do this:
class MyClass:
def my_method(self):
def callback(x):
return self.do(x)
return callback
def do(self, x):
print("done: {}".format(x))
then call:
m = MyClass()
callback = m.my_method()
callback(7)
Marko
--
https://mail.python.org/mailman/listinfo/python-list