Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72890
| References | <CAGGBd_pM5DGp85LVfeQgYwqS8DU8nuQL8Q8G5EzfQ5BX26fa-w@mail.gmail.com> |
|---|---|
| Date | 2014-06-07 10:20 +1000 |
| Subject | Re: Decorating one method of a class C with another method of class C? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10837.1402100435.18130.python-list@python.org> (permalink) |
On Sat, Jun 7, 2014 at 10:14 AM, Dan Stromberg <drsalists@gmail.com> wrote: > Is there a way of decorating method1 of class C using method2 of class C? > > It seems like there's a chicken-and-the-egg problem; the class doesn't > seem to know what "self" is until later in execution so there's > apparently no way to specify @self.method2 when def'ing method1. Since decoration happens at class creation, and arguments like self are available only when the method's actually called, no, there's no way you can define the method with something using information that doesn't exist yet and may change from one call to the next :) What are you trying to do, exactly? ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Decorating one method of a class C with another method of class C? Chris Angelico <rosuav@gmail.com> - 2014-06-07 10:20 +1000
csiph-web