[Python-Dev] Re: def fn (args) [dec,dec]:
Guido van Rossum
guido at python.org
Fri Aug 6 16:45:51 CEST 2004
> I'm having trouble finding a single piece from you where you
> outline the problems you have with the [decorators] after args,
> before :. Could you possibly post a message to python-dev
> stating your problems with it? It's the major one I've been
> unable to find your objections to.
And nobody else has expressed their objections to it either? :-)
Just look at it when either the list of decorators or the argument
list doesn't fit on one line:
funcattrs(grammar="'@' dotted_name [ '(' [arglist] ')' ]",
"""This method blah, blah.
It supports the following arguments:
- longArgumentOne -- a string giving ...
- longArgumentTwo -- a number giving ...
That's a total jumble of stuff ending with a smiley. (True story: I
left out the colon when typing up this example and only noticed in
Problems with this form:
- it hides crucial information (e.g. that it is a static method)
after the signature, where it is easily missed
- it's easy to miss the transition between a long argument list and a
long decorator list
- it's cumbersome to cut and paste a decorator list for reuse, because
it starts and ends in the middle of a line
Given that the whole point of adding decorator syntax is to move the
decorator from the end ("foo = staticmethod(foo)" after a 100-line
body) to the front, where it is more in-your-face, it should IMO be
moved all the way to the front.
(If I could design a language from scratch, I might want to move
docstrings to before the 'def' as well; I've come to appreciate this
in Java code. Fredrik Lundh's PythonDoc also uses comments prefixing
the method definition; he also uses @ so he should be happy with this
syntax, as he seemed to be when I mentioned it to him at EuroPython.)
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev