[Python-Dev] Re: PEP 318: Decorators last before colon

Phillip J. Eby pje at telecommunity.com
Thu Apr 1 12:47:11 EST 2004

At 09:08 AM 4/1/04 -0800, Michel Pelletier wrote:
>Later, Guido said:
> > 3) Prefix suite (could use a different keyword than 'decorate'):
> >
> >    decorate:
> >        funcattrs(foo=42)
> >        deprecated
> >        overrides
> >        classmethod
> >    def foo(cls, arg1, arg2):
> >        pass
>I don't really like it, but it's the only one that looks like Python to
>me.  Otherwise, I vote last-before-colon.  Line-preceding-def would be
>my last choice.

There is another option:

     as [classmethod]
     def blah(cls):

     as [singleton]
     class SignalManager:

     as [implementorOf(IFoo, forTypes=[Bar])]
     class FooToBarAdapter:

and it could also be on the same line, e.g.:

     as [classmethod] def blah(cls):

It reads a bit better with function definitions than with classes, but it's 
not too bad.  It's more of a replacement for the *[decorators] syntax than 
the 'decorate:' syntax, but it's an English word rather than a symbol, 
which brings back a bit more of the "Python look and feel".

More information about the Python-Dev mailing list