[Python-Dev] PEP 318: Decorators last before colon
Walter Dörwald
walter.doerwald at livinglogic.de
Wed Mar 31 13:23:49 EST 2004
Neal Norwitz wrote:
> [...]
> def foo(cls, lots, of, arguments, that, will, not,
> fit, on, a, single, line) \
> [classmethod, decorate(author='Someone', version='1.2.3',
> other='param')]:
> """The docstring goes here."""
>
> I hope that's a pretty unrealistic case. I think all of the proposed
> variants are ugly with the definition above. But, this may be more
> reasonable:
>
> def foo(cls, lots, of, arguments, all, on, a line) \
> [classmethod,
> decorate(author='Someone', version='1.2.3', other='param')]:
> """The docstring goes here."""
>
> Writing decorators this way is the least surprising to me. Although,
> I wish there was a better alternative.
Why not make the def look like a function call, i.e.:
def(classmethod,
decorate(author='Someone', version='1.2.3', other='param')) \
foo(cls, lots, of, arguments, all, on, a line):
"""The docstring goes here."""
Bye,
Walter Dörwald
More information about the Python-Dev
mailing list