[Python-Dev] Class decorators

Fred L. Drake, Jr. fdrake at acm.org
Wed Mar 29 08:11:06 CEST 2006


On Wednesday 29 March 2006 00:48, Fred L. Drake, Jr. wrote:
 > I think the existing usage for classes is perfectly readable.  The
 > @-syntax works well for functions as well.

On re-reading what I wrote, I don't think I actually clarified the point I was 
trying to make originally.

My point wasn't that I desparately need @-syntax for class decorators (I 
don't), or see it as inherantly superior in some way.  It's much simpler than 
that:  I just want to be able to use the same syntax for a group of use cases 
regardless of whether the target is a function or a class.

This fits into the nice-to-have category for me, since the use case can be the 
same regardless of whether I'm decorating a class or a function.  (I will 
note that when this use case applies to a function, it's usually a 
module-level function I'm decorating rather than a method.)

My other example, the zope.formlib example, has only ever involved a single 
decorator, and is always a method.  It could conceivably be applied to a 
nested class without much of a stretch, however.


  -Fred

-- 
Fred L. Drake, Jr.   <fdrake at acm.org>


More information about the Python-Dev mailing list