[Python-Dev] Decorator syntax J2 (decorate..def), with implementation

Nick Coghlan ncoghlan at iinet.net.au
Mon Aug 16 01:58:55 CEST 2004


Barry Warsaw wrote:

> On Fri, 2004-08-13 at 19:24, Bob Ippolito wrote:
> 
> 
>>My only problem with this syntax is that I expect the common cases 
>>(mine, anyway) to be zero or one decorators per function, so the extra 
>>block and indent seems a bit excessive compared to the current 
>>@prefix-symbol-decorator proposal(s).  It is, of course, far better 
>>than typing the function name three times though! :)
> 
> 
> Same here.  It trades one line at the end of the function for two (or
> more) before the beginning of the function.
> 
> -0

What about the variant which makes the block optional when there is only 
one decorator?

i.e.
   decorate: staticmethod
   def foobar():
     pass

The other thing I like about this version is that a folding editor like 
PythonWin can easily compress a decorated definition down to two lines, 
while leaving it clear that the function *is* decorated. That's not a 
huge point, though.

Cheers,
Nick.

-- 
Nick Coghlan               |  Eugene, Oregon
Email: ncoghlan at email.com  |             USA


More information about the Python-Dev mailing list