[Python-Dev] method decorators (PEP 318) (original) (raw)
Skip Montanaro skip at pobox.com
Sat Mar 27 13:26:41 EST 2004
- Previous message: [Python-Dev] method decorators (PEP 318)
- Next message: [Python-Dev] method decorators (PEP 318)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bernhard> Has somebody suggested the following yet?
Bernhard> def [classmethod] foo(cls, blooh, bla):
Bernhard> passYeah, I believe it's come up.
Bernhard> Putting the decorators between the "def" and the function name
Bernhard> has some advantages over the proposals I've seen so far:
Bernhard> - crucial information about the function and the meaning of
Bernhard> the parameters is given very early (this was an argument
Bernhard> made for putting the decorat before the argument list)I would propose a counterargument. Placing it between the argument list and the colon puts it "close enough" to the "def". I did a quick grep through the Python distribution just now and found 22198 function or method definitions. Of those, 20282 had the name and the entire argument list on the same line as the def keyword. That means in all but a small number of cases decorators would start on the same line as the def keyword.
Bernhard> - The name and the argument are together, so it still looks
Bernhard> similar to the function invocation (an argument made for
Bernhard> putting the decorators after the function list).Yes, but possibly several lines later, making it more difficult to find (you couldn't reliably grep for "^ *def foo" to locate a function definition) and forcing tools like the Emacs tags facility to be rewritten to handle the case where "def" and the function name don't appear on the same line.
Skip
- Previous message: [Python-Dev] method decorators (PEP 318)
- Next message: [Python-Dev] method decorators (PEP 318)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]