Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75669 > unrolled thread

Re:how to call back a method ?

Started byDave Angel <davea@davea.name>
First post2014-08-04 04:34 -0400
Last post2014-08-04 04:34 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re:how to call back a method  ? Dave Angel <davea@davea.name> - 2014-08-04 04:34 -0400

#75669 — Re:how to call back a method ?

FromDave Angel <davea@davea.name>
Date2014-08-04 04:34 -0400
SubjectRe:how to call back a method ?
Message-ID<mailman.12625.1407141231.18130.python-list@python.org>
elearn <elearn2014@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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web