what is the difference between functools.wraps and update_wrapper

python

Solution

`functools.wraps` is equivalent to:

def wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES):
    def decorator(wrapper):
        return update_wrapper(wrapper, wrapped=wrapped, ...)
    return decorator

It's actually implemented using `partial` instead of an inner function, but the effect is the same.

The purpose is to allow using it as a decorator:

 @wraps(f)
 def g():
     ...

is equivalent to:

def g():
    ...
g = update_wrapper(g, f)

Problem

I am not able to find what is the difference between these two python functions. `functools.wraps` and `update_wrapper` Can some give me some code example so that i can understand what is the difference

Original source