[Python-Dev] method decorators (PEP 318)
Phillip J. Eby
pje at telecommunity.com
Fri Mar 26 14:05:04 EST 2004
At 10:47 AM 3/26/04 -0800, Guido van Rossum wrote:
> > 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.
If it's only classmethod you're worried about obscuring, why not:
def foobar(class cls, otherarg, ...):
# ...
And then move all other decorators into some kind of delimited block in the
function body, just before the docstring.
More information about the Python-Dev
mailing list