Decorator Syntax

Ian Kelly ian.g.kelly at gmail.com
Tue Mar 22 00:50:12 EDT 2011


On Mon, Mar 21, 2011 at 7:31 PM, Benjamin Kaplan
<benjamin.kaplan at case.edu> wrote:
> On Mon, Mar 21, 2011 at 8:59 PM, Mike Patterson
> <mikepatterson77 at gmail.com> wrote:
>> In my Python class the other day, the professor was going over
>> decorators and he briefly mentioned that there had been this huge
>> debate about the syntax and using the @ sign to signify decorators.
>>
>> I read about the alternative forms proposed here (http://
>> www.python.org/dev/peps/pep-0318/#syntax-alternatives).
>>
>> Has anyone thought about just using dec to declare a decorator?
>>
>> For example:
>> dec dec2
>> dec dec1
>> def func(arg1, arg2, ...):
>>    pass
>> --
>
> dec and def look too similar. It would get confusing. Also, it
> wouldn't be immediately obvious that the line is associated with the
> function declaration below. The whole point in the decorators is that
> it makes it easier to tell that the function is being wrapped.

Also "dec" would then have to become a keyword.  Unnecessary
keywording is frowned upon because it breaks any script that happens
to use the keyword as a name, thus creating backward
incompatibilities.  And I'm willing to bet that there are plenty of
scripts out there that use "dec" as a name for Decimal objects.



More information about the Python-list mailing list