How I can to decorate function with parameters? such as print_reverse(x)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How I can to decorate function with parameters? such as print_reverse(x)?

27th Jul 2016, 7:31 PM
Sweemyn
1 Answer
+ 2
def decor(func): def wrap(txt): print("============") func(txt) print("============") return wrap @decor def print_text(txt): print(txt) print_text("Hello World"); print_text("Goodbye world") print_text("This might actually start to make sense...")
28th Jul 2016, 1:25 AM
Frédéric Charette
Frédéric Charette - avatar