A decorator syntax not yet mentioned (I think!)

Peter Hansen peter at engcorp.com
Thu Aug 12 22:53:42 EDT 2004


Mark Bottjer wrote:

> Peter Hansen wrote:
> 
>> Mark Bottjer wrote:
>>> With this
>>> syntax, though, the decorate block changes how the def statement is 
>>> handled, even though they are at the same indentation level.
>>
>> Changes it how?  The definition of this whole decorator idea has been
>> that it is equivalent to applying the decorator functions *after* the
>> def has completed, as in "func = decorator(func)".  This does not
>> in any way changed how the def statement itself is handled.
> 
> Except that the action happens magically after the def, even though the 
> decorator is before it. To me, this has the appearance of changing the 
> action of def. I'm trying to argue based on how it appears, rather than 
> how we know it to be implemented.

I understand that.  What I don't understand is why you make
this complaint about the indented form, when the non-indented
form with @decorator has exactly the same issue!  In all
cases, pre-def is weird in that the declarative lines that
decorate the function lead to action *after* the def is
closed, whether the decorators are indented or not.

-Peter



More information about the Python-list mailing list