<div dir="ltr"><br><div class="gmail_quote">On Mon, Jul 28, 2008 at 11:12 AM, Gabriel Genellina <span dir="ltr"><<a href="mailto:gagsl-py2@yahoo.com.ar">gagsl-py2@yahoo.com.ar</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
En Sun, 27 Jul 2008 15:26:39 -0300, Themistoklis Bourdenas <<a href="mailto:tbourden@doc.ic.ac.uk">tbourden@doc.ic.ac.uk</a>> escribió:<br>
<div class="Ih2E3d"><br>
</div><div class="Ih2E3d">> On a related note, as the actual instance method of myclass is not foo but<br>
> decorate(foo), why are they called method decorators? This does not decorate<br>
> methods, they decorate functions and eventually the decorated functions<br>
> become methods. The name method decorator sounds a bit misleading to me.<br>
<br>
</div>Where have you found it? I've always seen the expression "function decorator" or just "decorator", not "method decorator".<br>
<div class="Ih2E3d"></div></blockquote><div><br>well a few occurrences of it can be found in PEP 318<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
> So returning to my original question is there any way I can get the class<br>
> inside decorate()? I guess there is not, but just asking to make sure.<br>
<br>
</div>"the class inside decorate"? What do you mean? The type of the x instance in an x.foo() call? That should be determined inside the wrapped function -when it is actually called-.<br>
<div class="Ih2E3d"><br></div></blockquote></div>Yes, what I was hoping is that it might be possible to get the name of the class the function is eventually is going to be bound to, but I guess that's not very likely to be possible. I wanted the name well before the function is called, actually even before an instance of the class is created. Anyway, I 've solved my problem with other means. Just out curiosity though, has there been any talk about actual method decorators? I guess you can work around them with the introduction of class decorators or even now with meta-classes, but you have to wrap methods manually with no syntactic sugar.<br>
<br>Cheers,<br>
Themis<br><br></div>