what is the difference between functools.wraps and update_wrapper

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)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)