[Python-Dev] Updated PEP 362 (Function Signature Object) (original) (raw)

Yury Selivanov yselivanov.ml at gmail.com
Thu Jun 7 15:32:22 CEST 2012


On 2012-06-07, at 9:28 AM, Michael Foord wrote:

On 6 Jun 2012, at 18:28, Yury Selivanov wrote:

On 2012-06-06, at 1:13 PM, Alexandre Zani wrote: Never copy attributes by hand, always use 'functools.wraps'. It copies 'name', 'qualname', and bunch of other attributes to the decorator object.

We'll probably extend it to copy signature too; then 'signature(decor(f))' will be the same as 'signature(f)'. I don't think functools.wraps can copy the signature by default - it's not uncommon to have decorators that modify signatures. A new parameter to functools.wraps defaulting to False?

http://mail.python.org/pipermail/python-dev/2012-June/120021.html

We just won't copy it at all. See the link above.

'functools.wraps' already sets 'wrapped' reference to the wrapped function, so we can easily traverse the chain to either first function with signature defined, or to the most inner-decorated function and get a signature for it.



More information about the Python-Dev mailing list