0
Why? :|
```def decor(func): def wrap(): print("============") func() print("============") return wrap def print_text(): print("Hello world!") decor(print_text)``` Why doesn't it work? we have to add empty parenthesis after decor(print_text) to get output. Why? decor is a function that takes function as it's arguments and everything is ok; so why () ? :|
2 Answers
+ 4
Decor function returns a function. You need to store it and then call it.
x = decor(print_text)
x()
+ 2
You are right but see the decor function properly, it returns wrap function to the decor function when called so now you need to call the actual wrap function as well to get output