[Python-Dev] PEP 318 - posting draft
Bob Ippolito
bob at redivi.com
Tue Mar 23 12:26:21 EST 2004
On Mar 23, 2004, at 12:02 PM, Skip Montanaro wrote:
> Here's the current state of PEP 318. I have to take a break from this
> to
> get some real work done and may not get back to it in a major way for
> awhile. I received a significant rewrite of Kevin Smith's most recent
> version from Jim Jewett and incorporated much of what he wrote,
> modifying a
> lot of it along the way, but have still not digested everything he
> sent me.
>
> I've tried to reflect the concensus which seems to be emerging on the
> python-dev list, though I suspect I've done a poor job of that. The
> discussions there and on comp.lang.python have ranged far and wide and
> thus
> resist summary in a finite amount of time. I recommend interested
> comp.lang.python readers spend some time in the python-dev archives for
> February and March if they find major fault with the current state of
> the
> proposal.
>
> If you post corrections or comments to either list I should see them.
>
> Skip Montanaro
>
> -----------------------------------------------------------------------
> -------
> PEP: 318
> Title: Function/Method Decorator Syntax
> Version: $Revision: 1.5 $
> Last-Modified: $Date: 2004/03/23 16:41:17 $
> Author: Kevin D. Smith <Kevin.Smith at theMorgue.org>,
> Jim Jewett <jimjjewett at users.sourceforge.net>,
> Skip Montanaro <skip at pobox.com>
> Status: Draft
> Type: Standards Track
> Content-Type: text/x-rst
> Created: 05-Jun-2003
> Python-Version: 2.4
> Post-History: 09-Jun-2003, 10-Jun-2003, 27-Feb-2004, 23-Mar-2004
--snip--
> with an alternative that places the decoration in the function's
> declaration::
>
> def foo(cls) using [synchronized(lock), classmethod]:
> pass
Shouldn't the using keyword go away, so it's consistent with the
current implementation?
> Current Implementation
> ======================
>
> Michael Hudson has posted a `patch`_ at Starship, which implements the
> proposed syntax and left-first application of decorators::
>
> def func(arg1, arg2, ...) [dec1, dec2]:
> pass
>
> is equivalent to::
>
> def func(arg1, arg2, ...):
> pass
> func = dec2(dec1(func))
>
> though without the intermediate creation of a variable named ``func``.
>
> .. _patch:
> http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar.diff
The current implementation is here, as far as I know:
http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar-3.diff
> Possible Extensions
> ===================
>
> The proposed syntax is general enough that it could be used on class
> definitions as well::
>
> class foo(object) [dec1, dec2, ...]:
> class definition here
>
> Use would likely be much less than function decorators. The current
> patch only implements function decorators.
The current patch *does* implement class decorators, with this syntax.
-bob
More information about the Python-Dev
mailing list