PEP 318

Ronald Oussoren oussoren at cistron.nl
Tue Mar 23 01:41:03 EST 2004


On 23-mrt-04, at 1:15, Jess Austin wrote:

> I'll preface by saying that I haven't fully grokked all the possible
> uses of decorators.  Also, I can sympathize with the complaints about
> seeing a function definition and then seeing a classmethod call on
> that function 50 lines later (actually that seems like a case for
> refactoring but never mind).  b-)
>
> The brackets and the 'as' both seem awkward to me.  Also, introducing
> a requirement that definition and decoration take place on the same
> line seems to limit the the possibilities of decoration.  Perhaps my
> class wants to offer several faces of the same method:
>
> class foo(object):
>     def __foo_method(...)
>         ....
>     bar = decorator1(__foo_method)
>     baz = decorator2(__foo_method, arg1, arg2)
>
> I can't imagine the exact use for this, but I can imagine that there
> could be a use.  If the syntax remains as it is, that is.  This PEP
> seems to shoot itself in the foot in this respect.

The syntax in PEP318 is syntactic sugar for the most common use of 
function decorators, the current syntax would still be supported.

Ronald





More information about the Python-list mailing list