[Python-Dev] Re: def ... decorate

Josiah Carlson jcarlson at uci.edu
Fri Aug 13 21:06:35 CEST 2004


On Fri, 13 Aug 2004 19:06:13 +0100
Gareth McCaughan <gmccaughan at synaptics-uk.com> wrote:

>     def p_statement_expr(self, p):
>         """docstring goes here"""
>         print p[1]
>     decorated:
>         staticmethod
>         grammarrule('statement : expression')
>         version("Added in 2.4")
>         deprecatedmethod
>         type_(None)
> 
> which keeps the arguments with the function name,
> keeps the body right after the name and arguments, and
> puts the decoration after the body which corresponds
> with the order in which things actually happen (though
> not necessarily the best order for understanding the
> code).

You seem to have missed the point of function decorations entirely.  We
already have what you offer in current Python syntax.  The point was to
move decorations to near/next to the function signature.

Read the PEP:
http://www.python.org/peps/pep-0318.html


> I actually quite like this. It seems more Pythonic
> than the @foo proposal. Its obvious problem is that
> it involves something that looks at first glance like
> an ordinary suite of statements or expressions, but
> whose interpretation is substantially different. At
> least the @foo proposal avoids that.

What you like is what has existed with Python since the beginning.

 - Josiah



More information about the Python-Dev mailing list