all Python 3functoolsfunction
functools.update_wrapper
functools
Copy metadata (__name__, __doc__, …) from a wrapped function onto the wrapper.
Syntax
functools.update_wrapper(wrapper, wrapped)
You rarely reach for it directly, since @functools.wraps is just this function packaged as a decorator. Call it by hand when the wrapper is not a plain def inside a decorator — a functools.partial object, say, or an instance of a class with __call__. It mutates the wrapper in place (returning it too) and stores a __wrapped__ back-reference, which is what lets inspect.signature report the original parameters instead of (*args, **kwargs).
Examples
import functools
def orig():
'док'
def wrap():
pass
functools.update_wrapper(wrap, orig)
print(wrap.__name__) # → orig
See also
Open in the full glossarydocs.python.orgReport an inaccuracy