Functional Functions

functools.update_wrapper()

Copy selected metadata from a wrapped callable to its wrapper and set __wrapped__. It changes metadata, not the actual calling convention.

Formal Syntax & Structure

python syntaxpython
functools.update_wrapper(wrapper, wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES)

Parameters & Attributes

NameTypeDescription
wrappercallableWrapper receiving metadata.
wrappedcallableOriginal callable whose metadata is copied.
assignedtuple[str, ...]Attribute names to assign from the wrapped object.
updatedtuple[str, ...]Attribute names whose mappings are updated.

Return Value

callable

The callable result described above.

Working Example

Example Snippetpython
import functoolsdef original(x): return xdef wrapper(*args): return original(*args)functools.update_wrapper(wrapper,original)print((wrapper.__name__,wrapper.__wrapped__ is original))
Python Reference