how to call back a method ?

Dave Angel davea at davea.name
Mon Aug 4 04:34:11 EDT 2014


elearn <elearn2014 at gmail.com> Wrote in message:
> 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:
> 
> 
>        File "<stdin>", line 1
>          def callback(self.do,x):
>                       ^
>      SyntaxError: invalid syntax
> 
> 
> `do` is a method in my class ,how to write the code?
> 

Without some context,  answering the question is a shot in the dark. 

Is callback supposed to be a member function,  and is it always
 going to be calling do () on the same object that it was called
 on ? Then try

    def callback (self, x):
        return self.do (x)

But there are many other scenarios.  Show us some sample code
 where it's actually being called, and we might have a better
 chance of guessing what you need.

-- 
DaveA




More information about the Python-list mailing list