On Mon, Jul 28, 2008 at 11:12 AM, Gabriel Genellina <[EMAIL PROTECTED]>wrote:
> En Sun, 27 Jul 2008 15:26:39 -0300, Themistoklis Bourdenas < > [EMAIL PROTECTED]> escribió: > > > On a related note, as the actual instance method of myclass is not foo > but > > decorate(foo), why are they called method decorators? This does not > decorate > > methods, they decorate functions and eventually the decorated functions > > become methods. The name method decorator sounds a bit misleading to me. > > Where have you found it? I've always seen the expression "function > decorator" or just "decorator", not "method decorator". > well a few occurrences of it can be found in PEP 318 > > > So returning to my original question is there any way I can get the class > > inside decorate()? I guess there is not, but just asking to make sure. > > "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-. > > 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. Cheers, Themis
-- http://mail.python.org/mailman/listinfo/python-list