[Python-Dev] Proposed tweaks to functools.wraps (original) (raw)
Raymond Hettinger raymond.hettinger at gmail.com
Wed Aug 11 21:16:54 CEST 2010
- Previous message: [Python-Dev] Proposed tweaks to functools.wraps
- Next message: [Python-Dev] Proposed tweaks to functools.wraps
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Aug 11, 2010, at 6:00 AM, Steven D'Aprano wrote:
@wraps(f) def func(*args): dosomething() 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
- Previous message: [Python-Dev] Proposed tweaks to functools.wraps
- Next message: [Python-Dev] Proposed tweaks to functools.wraps
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]