the task is to call a function 4 times using decorator. The solution is:
def my_decorator (func):
def wrapper():
func()
func()
func()
func()
return wrapper
@my_decorator
def printer_hp():
print('I am printer HP 4700 LaserJet')
return 0
printer_hp()
HOWEVER, if I move func to the wrapper args and put parentheses for the @my_decorator:
def my_decorator ():
def wrapper(func):
func()
func()
func()
func()
return wrapper
@my_decorator()
def printer_hp():
print('I am printer HP 4700 LaserJet')
return 0
the function is called automatically 4 times without calling it in the main program. Why is that?