[Python-Dev] Re: Decorators: vertical bar syntax

Andrew Koenig ark-mlist at att.net
Sun Aug 8 18:21:35 CEST 2004


> Did you omit the full wink?  Or did you forget that | is already a binop?
> Strictly speaking I guess it's unambiguous if one doesn't allow
> arbitrary expressions as decorators, but...

Neither, actually.  It didn't occur to me that there might be an ambiguity
any more than it occurs to me that f(3, 4) could be ambiguous in C because
the comma might be an operator.  I imagined the following rule:  If a
statement begins with "def", then every | outside parentheses delimits a
decorator.  If you insist on using an expression with | in it as a
decorator, you have to parenthesize it.

I can see now that even though this suggestion isn't really syntactically
fuzzy, it might be considered too fussy.  Still, I like it better than the
prefix @ idea.

I even realize why I don't like the @ syntax.  It's not so much reserving @
as it is that it's a prefix syntax.  It is ingrained in me that "def" starts
a function definition, and now it doesn't any more.  So, for example, if I
use my editor to search for "def", I have to back up to see whether I've
missed something before it.



More information about the Python-Dev mailing list