[Python-ideas] Decorator syntax

MRAB python at mrabarnett.plus.com
Thu Sep 3 00:36:11 CEST 2009

Nick Coghlan wrote:
> MRAB wrote:
>>> However, this looks better to me:
>>>    @(a + b)
>>>    @(a or (c and d))
>> Conditions in 'if' and 'while' statements don't need parentheses, so why
>> do decorators?
> Those are already closed by the colon so requiring parentheses would be
> redundant:
>  if a + b:
>  while a + b:
I forgot about 'return':

     return a + b

> The minimalist tweak would be to follow Guido's preference and just
> accept subscripting in addition to calls.
>>> So, in terms of Grammar/Grammar, what about
>>>    decorator: '@' atom trailer* NEWLINE
>> I say "keep it clean", ie no parentheses except where operator priority
>> or clarity require them.
> I actually agree with Georg that this is a case where clarity favours
> enforced parentheses for expressions that are otherwise non-atomic.
> Things like variable references, function calls and subscripting are
> already atomic so the parentheses would be optional in those cases.
> However, as long as Guido remains -0 extension to arbitrary expressions
> isn't going to happen, parentheses or no parentheses.

More information about the Python-ideas mailing list