[Python-Dev] Re: new syntax for wrapping (PEP 318)

Bob Ippolito bob at redivi.com
Thu Feb 26 12:56:56 EST 2004


On Feb 26, 2004, at 12:47 PM, Christian Tismer wrote:

> Bob Ippolito wrote:
>
> ...
>
>> Sorry, but you understate the capabilities of this new syntax and 
>> overestimate the need for future related syntax.  Try the following 
>> decorators in the current Python interpreter, using the clumsy def 
>> foo(): ... foo = decorator(foo) pattern:
>
> Ok, let me give a total different approach that doesn't use new
> syntax, just a little new semantics.
> No idea whether it is better, but at least it is easy to read.
> (Bob, I didn't know where to thow this in, so I used your message).
>
> We now have:
>
> class klass:
>   def foo():...
>   foo = decorator(foo)
>
> Now how about this
>
> class klass:
>   foo = decorator
>   def foo():...
>
>   baz = decorator1, decorator2
>   def baz(): ...
>
> The simple idea is to change semantics that if a name already
> exists before a def, it is checked whether it is a decorator
> function or a tuple of these, and if so, they are called.
>
> call-me-dumb-but-don't-call-me-perlish - ly y'rs - chris  :-))

That's too magical for me, and it means I have to spell out the name of 
the function (which may be quite long) twice.. which is better than 
three times, but not as good as once.

-bob




More information about the Python-Dev mailing list