[Python-Dev] method decorators (PEP 318)

Guido van Rossum guido at python.org
Fri Mar 26 13:47:04 EST 2004


> It appears to be a surprisingly important detail.

I'm anal about trying to find the optimal syntax given incompatible
constraints.

> Tossing out another idea:
> 
>      foobar:
>          author = "Guido van Rossum"
>          deprecated = True
>      def foobar(self, arg):
>          pass
> 
> The declaration block must be followed immediately by a class or def 
> statement.  It looks elegant to me.

The current parser can't deal with "NAME ':'" as a syntax rule,
because expressions also start with NAME.

I also don't like that you have to repeat the function name.

And this would hide the "important" decorators (e.g. classmethod)
amongst a large collection of metadata (unless you want to combine
this with the "def foo [classmethod] (cls, a, b, c):" syntax.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list