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

Nick Coghlan ncoghlan at iinet.net.au
Thu Feb 19 21:48:10 EST 2004

Phillip J. Eby wrote:

> At 06:48 PM 2/19/04 -0500, Jewett, Jim J wrote:
>> I think this may be one reason this didn't happen before;
>> wrapping is good, but it isn't entirely obvious how to
>> write it or exactly what it should mean.  Given that, it
>> might be premature to use up the [] syntax.
> Well, I personally prefer the 'as' syntax for both class and function 
> decorators.
> As for the semantics of class decorators, I would propose that they be 
> identical to the semantics for function decorators.  I don't think 
> there's a point to adding more ways to spell '__metaclass__'.  :)

Do you mean:

   class decorated as decorator: pass

is equivalent to:

   class decorated: pass
   decorated = decorator(decorated)


And to get PJE's example to work would require a 'protocol decorator' 
method such as 'IFoo_decorator' which took a class as an argument, told 
PyProtocols about the class and the interface it supports, and then 
returned either the original class, or a suitably changed version?


Nick Coghlan               |     Brisbane, Australia
Email: ncoghlan at email.com  | Mobile: +61 409 573 268

More information about the Python-Dev mailing list