+ 1
decorator problem
hi, dears somebody can tell me that why The decor function does not return the wrap function as its result to below code???? def decor(func): print(1) def wrap(): print(2) print("============") func() print("============") return wrap def print_text(): print(3) print("Hello world!") decor(print_text())
2 Réponses
+ 2
This is the example I found in the Sololearn course, maybe you should compare it with yours:
def decor(func):
def wrap():
print("============")
func()
print("============")
return wrap
def print_text():
print("Hello world!")
decorated = decor(print_text)
decorated()
0
I compare it, but does not understand can explanation simple?
(test to online interpreter => https://snakify.org/en/lessons/sets/)