Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75663
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
| Newsgroups | comp.lang.python |
| Subject | Re: how to call back a method in python3? |
| Date | Mon, 04 Aug 2014 18:18:33 +1200 |
| Lines | 19 |
| Message-ID | <c48mtrFim9vU1@mid.individual.net> (permalink) |
| References | <mailman.12616.1407121329.18130.python-list@python.org> <87y4v4kdqk.fsf@elektro.pacujo.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net qnWNl0qMiSMBYh1Keht8vAwFc+jsHYLqqjmrgRWpH8ffr3ZpWc |
| Cancel-Lock | sha1:6VGSabjqpHLaYs49LER+kKJHb9s= |
| User-Agent | Mozilla Thunderbird 1.0.5 (Macintosh/20050711) |
| X-Accept-Language | en-us, en |
| In-Reply-To | <87y4v4kdqk.fsf@elektro.pacujo.net> |
| Xref | csiph.com comp.lang.python:75663 |
Show key headers only | View raw
Marko Rauhamaa wrote:
> 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))
Or more simply:
def my_method(self):
return self.do
--
Greg
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
how to call back a method in python3? "水静流深" <1248283536@qq.com> - 2014-08-04 09:56 +0800
Re: how to call back a method in python3? Marko Rauhamaa <marko@pacujo.net> - 2014-08-04 08:47 +0300
Re: how to call back a method in python3? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-08-04 18:18 +1200
csiph-web