[Python-Dev] Re: PEP 318: Decorators last before colon (original) (raw)

Michel Pelletier michel at dialnetwork.com
Thu Apr 1 13:07:35 EST 2004


On Thu, 2004-04-01 at 09:47, Phillip J. Eby wrote:

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.

Agreed, I missed this one. It's not too bad with classes if you can warp your mind to think of "to class" as a verb like "to define".

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".

One minor nit, why use the brackets at all?

as sychronized, sharkfin(size=10) def VWBug(...):

that looks better to me than:

as [sychronized, sharkfin(size=10)] def VWBug(...):

without brackets it looks more to me like Python, you'd never see:

from foo import [bar, baz]

For longer lists of decorators use the familiar tuple rule, wrap in parens:

as (sychronized, sharkfin(size=10), deprecated) def VWBug(...):

-Michel



More information about the Python-Dev mailing list