var = float(input('Enter a number: '))
def math_test(func):
def wrapper(*args, **kwargs):
func(var)
return wrapper
@math_test
def times10(x):
print(x * 10)
times10()
Why is it that when I call the function times10(), that I don't need to put the argument var in the brackets?
When I didn't type the argument var when I called func() I got an error saying requiring positional argument x...so when I put var in times10() I got the same error.
However when I placed the argument in func() it worked fine.
Shouldn't the wrapper function know that the argument in times10(), which would be var, should also be the argument in func()?
Edit:
var = float(input('Enter a number: '))
def math_test(func):
def wrapper(*args, **kwargs):
func(*args, **kwargs)
return wrapper
@math_test
def times10(x):
print(x * 10)
times10(var)