Rather than decorators, how about sections?

Paul Morrow pm_mon at yahoo.com
Wed Aug 11 11:38:06 EDT 2004


I like many am not wild about the <at> operator.  I also don't think 
that the decorator syntax should be so directly attached to the method, 
since what we're trying to do is to say something about the 
*relationship between* a method and a class (e.g. "method m is a 
staticmethod of class C").

So if we are going to extend the Python grammar to support this sort of 
thing (which I believe is a good idea), my preference would be to 
introduce named sections within a class definition, such as...

     class Foo(object):
         staticmethods:
             def baz(a,b):
                 print "I'm a static method."
             def bez(c,d):
                 print "I'm a static method too."

         classmethods:
             def biz(klass):
                 print "I'm a class method."


         def __init__(self):
             print "We all know what I am."





More information about the Python-list mailing list