PEP-0318

Anthony Baxter anthonybaxter at gmail.com
Sun Aug 8 21:34:39 EDT 2004


On Sun, 08 Aug 2004 19:49:51 -0400, Mark Bottjer
<mark_bottjer at hotmail.com> wrote:
> > I noticed you posted the "@decorators at the top of function body"
> > idea right before I posted it here, too.  See the "compromise?"
> > thread.
> 
> This idea seems to have occurred to a few people independently. Another
> guy apparently beat me to posting it by a day or so. Here's hoping that
> someone with "cred" will see it and like it enough to promote it to GvR.

Guido has ruled out decorators at the top of function body, on the grounds
that it looks like something that would be executed as part of the function,
but isn't. FWIW, in the same thread he's noted that having docstrings where
they are is problematic in this respect. Fortunately, with the new decorator
syntax, we can fix this...

def doc(docstring):
    def add_doc_string(func, docstring=docstring):
        func.__doc__ = docstring
        return func
    return add_doc_string

@doc("This function frobulates an input sequence")
def frob(seq):
    ....



More information about the Python-list mailing list