A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-June/119997.html below:

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

[Python-Dev] Updated PEP 362 (Function Signature Object) [Python-Dev] Updated PEP 362 (Function Signature Object)Yury Selivanov yselivanov.ml at gmail.com
Wed Jun 6 19:28:23 CEST 2012
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 some_func(a,b):
>        do_stuff using f
>    some_func.__name__ = f.__name__
>    return some_func
> 
> What are the name and fully qualified names in the signature for the
> returned function? some_func.__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)'.

-
Yury
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4