Mar-19-2018, 05:56 PM
(Mar-19-2018, 05:48 PM)micseydel Wrote: From the way you describe it, your decorator will not care what the function it's decorating does. Am I correct in saying what you actually want is a decorator which multiplies the first argument by a value provided to the decorator, before calling the decorated function- YES!
I have got this far in terms of trying to achieve it:
def primer(func, z): def wrapper(*args,**kwargs): # I need to multiply the first argument by z so something like arg=arg*z before I pass this argument into the function in next line return func(*args, **kwargs) return wrapper @primer def add(first, second): return first+second