def func_needs_decorator():
print("I wanna a decorator urgently")
def new_decorator(original_funct):
def wrapper_funct():
print("Some extra code before the original function")
original_funct()
print("Some extra code after the original funciton")
return wrapper_funct()
func_needs_decorator = new_decorator(func_needs_decorator)
print(func_needs_decorator())
>>>'NoneType' object is not callable
I couldn't understand why I'm getting that error.Why am I getting that error?How can i fix it?Can you tell me the procces of this code?How does it work?
You are calling wrapper_funct
and returning its return value instead of returning wrapper_funct
itself.
return wrapper_funct()
should be
return wrapper_funct