0

The best way to understand the decoration

Hi guys! Code: **************** def decor(func): print ("decor(func) is running one time only.") def wrap(): print("============") func() print("============") return wrap def print_text(): print("Hello world!") print_text = decor(print_text) print("decor(func) will never work again.") print_text(); print_text(); print_text(); Output: **************** decor(func) is running one time only. decor(func) will never work again. ============ Hello world! ============ ============ Hello world! ============ ============ Hello world! ============

29th Aug 2017, 3:13 AM
Alex Philippov
2 odpowiedzi
+ 8
Deconstruct it and rebuild it function by function?
29th Aug 2017, 3:43 AM
jay
jay - avatar
0
What is the question?
29th Aug 2017, 3:20 AM
Amaras A
Amaras A - avatar