AI engineering glossary · Python advanced
What is functools.wraps?
functools.wraps: A decorator from the functools module used inside your own decorators to copy the original function's name, docstring and other metadata onto the wrapper. Without it, the decorated function appears to have the wrapper's identity.
functools.wraps: an example
Adding @wraps(func) above the wrapper keeps train.__name__ equal to 'train' instead of 'wrapper'.
Related terms
More Python advanced terms
Where you learn it
functools.wraps is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.