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/2010-August/103019.html below:

[Python-Dev] Proposed tweaks to functools.wraps

[Python-Dev] Proposed tweaks to functools.wrapsRaymond Hettinger raymond.hettinger at gmail.com
Wed Aug 11 21:16:54 CEST 2010
On Aug 11, 2010, at 6:00 AM, Steven D'Aprano wrote:

> @wraps(f)
> def func(*args):
>    do_something()
>    return f(*args)
> 
> then func.__wrapped__ gives f. If f itself wraps (say) g, and g wraps h, 
> then you have:
> 
> func.__wrapped__ => f
> func.__wrapped__.__wrapped__ => g
> func.__wrapped__.__wrapped__.__wrapped__ => h
> 
> and so on, until you reach a function that doesn't wrap anything and 
> doesn't have a __wrapped__ attribute.
> 
> 
> I'm +1 on the proposal.

+1 from me also.

The ability to introspect is basic to Python's design.
Objects know their class, functions know their code objects,
bound methods know both their underlying function, 
classes know their own class dictionary, etc.


Raymond



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