Is it possible to wrap a function call using python decorators?
I don't want to implement a wrapper for every function of a module individually.
I would like to have something like
def a(num):
return num
@double_the_value
a(2)
returning 4
without the need of having access to the implementation of a
.
Would a global wrapper like
def multiply(factor, function, *args, **kwargs):
return factor * function(*args, **kwargs)
be the better choice in this case?
multiply(factor, function)
, since what you're asking is not possible. – Fleabitten