[Python-Dev] Re: def fn (args) [dec,dec]: (original) (raw)

IxokaI ixokai at gmail.com
Fri Aug 6 19:23:19 CEST 2004


On Fri, 06 Aug 2004 09:58:59 -0700, Guido van Rossum <guido at python.org> wrote:

> decorate classmethod: > def foo(arg1,arg2): > ... Somebody should add to the PEP that solutions requiring an extra indent level for the function have a drawback. Having your minimal indent level be three deep is painful for those using limited-width windows; also, the inconsistent indentation between methods with and without decorators would be a readability problem (plus, adding/removing decorators would require reindenting the entire method body).

Doh. That's true... What about:

class foo: def bar(arg1, arg2): | staticmethod | interface(int, string) """ This is my doc string """ for i in range(arg1): print arg2

I've been convinced that the list-after-def is bad, but still loathe @ as painful, and really, really, really hate how the @decorators do not fit into our indented world of grouping stuff together well. I think a keyword like, say, "using" instead of | would be even better, but... :)

class foo: def blah(self): return None | staticmethod | interface(int, string) def bar(arg1, arg2): """ This is my doc string """ for i in range(arg1): print arg2

In that example, only knowing "the bar goes down" clearly connects the decorators to the right method. And if 'blah' was one of those bad-styled one-line-functions...

--Stephen



More information about the Python-Dev mailing list