[Python-Dev] method decorators (PEP 318)
skip at pobox.com
Fri Mar 26 15:10:41 EST 2004
Jack> I don't think because it has been neglected for so long we need to
Jack> make it _more_ important that the arg list, as a reparation.
Can you say "affirmative action"? <wink> At any rate, I agree that moving
it up somewhere near the "def" is probably good enough. I think the
function name and the arglist are should be more visually important.
I don't think we're going to wind up with everybody suddenly adding
decorations to every function they write (I have yet to use classmethod or
staticmethod). Except in extreme cases (PEAK sort of sounds like it might
be one), most functions will be of the current type. When I go back and
look at the beginning of a function's definition it is almost always to see
how to call it. I'd like that to be just as easy for decorated functions as
the vanilla ones.
Guido> (For those worried that the function attribute sets appear to
Guido> belong to the body, I point to the precedent of the docstring.
Guido> IMO the start of the function body is a perfectly fine place for
Guido> metadata about a function.)
The docstring is a bit of a different beast. They were added before general
function attributes, right? As such, they are a partial solution to a more
general problem. Had function attributes been available at that time the
special nature of "if the first object in the module/function/class is a
string literal, make it the docstring" wouldn't have been (as) necessary.
More information about the Python-Dev