Код следующий, в соответствии с курсом:
def new_decorator(func):
def wrap_func():
print("code here before executing func")
func()
print("func() has been executed")
return wrap_func()
@new_decorator
def func_needs_decorator():
print("this function is in need for a decorator")
func_needs_decorator()
, и результат будет следующим:
code here before executing func
this function is in need for a decorator
func() has been executed
Traceback (most recent call last):
File "decorators.py", line 17, in <module>
func_needs_decorator()
TypeError: 'NoneType' object is not callable
Однако, если я удалю последнюю строку из кода (строка 17, func_needs_decorator ()), сообщения об ошибке нет, и результат следующий:
code here before executing func
this function is in need for a decorator
func() has been executed
Я был бы признателен за ваши советы, почему последняя строка вызывает проблему:)