[Python-Dev] Updated PEP 362 (Function Signature Object) (original) (raw)
Michael Foord fuzzyman at voidspace.org.uk
Thu Jun 7 15:28:08 CEST 2012
- Previous message: [Python-Dev] Updated PEP 362 (Function Signature Object)
- Next message: [Python-Dev] Updated PEP 362 (Function Signature Object)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 6 Jun 2012, at 18:28, Yury Selivanov wrote:
On 2012-06-06, at 1:13 PM, Alexandre Zani wrote:
A question regarding the name. I have often seen the following pattern in decorators:
def decor(f): def somefunc(a,b): dostuff using f somefunc.name = f.name return somefunc What are the name and fully qualified names in the signature for the returned function? somefunc.name or f.name? 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?
Michael
- Yury
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
-- http://www.voidspace.org.uk/
May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html
- Previous message: [Python-Dev] Updated PEP 362 (Function Signature Object)
- Next message: [Python-Dev] Updated PEP 362 (Function Signature Object)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]