[Python-Dev] PEP 318: Preserve function signatures

Ka-Ping Yee python-dev at zesty.ca
Tue Mar 30 06:17:23 EST 2004


There has been some discussion about whether decorators are required
to be callable, accept callables, or return callables.

I would like to ask that the PEP recommend (perhaps strongly, but not
require) that decorators preserve function argument signatures whenever
it is reasonable to do so.  (That is, given a three-argument function
returning a string, a typical decorator should produce another three-
argument function returning a string.)

I think this is a good idea because the original function signature is
the most obvious documentation of its arguments.  If i see:

    def func(foo, bar, *arg) [decorator]:
        ...

i am inclined to expect that func will accept two arguments named foo
and bar and optionally some more arguments, with their meanings having
something to do with their names and the descriptions in the docstring.

This need not be enforced by any interpreter mechanism.  I just think
it should be the encouraged practice.


-- ?!ng



More information about the Python-Dev mailing list