I have two code snippets that look almost identical to one another. However, when I run them, the first code snippet works perfectly. When I run the second script, I get the error: TypeError: 'NoneType' object is not callable
Why???
I've tried renaming the functions. I've tried changing the text in the functions.
def cough_dec(func):
def func_wrapper():
print("*cough*")
func()
print("*cough*")
return func_wrapper
@cough_dec
def question():
print('can you give me a discount on that?')
@cough_dec
def answer():
print("it's only 50p, you cheapskate")
question()
answer()
=============================================
def c_dec(func):
def wrapper_func():
print('something')
func()
print('anything')
return wrapper_func()
@c_dec
def say_hello():
print("Hello World!")
@c_dec
def bye():
print("Goodbye World!")
say_hello()
bye()
If I remove the parentheses in the second snippet, everything works great, but why?