+ 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())

5th Aug 2018, 10:15 AM
وحید پیوندی
وحید پیوندی - avatar
2 odpowiedzi
+ 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()
5th Aug 2018, 12:38 PM
Paul
Paul - avatar
0
I compare it, but does not understand can explanation simple? (test to online interpreter => https://snakify.org/en/lessons/sets/)
6th Aug 2018, 9:43 AM
وحید پیوندی
وحید پیوندی - avatar