0
How can upper() works in wrapper?
I can’t get why below codes doesn’t work. Help me, somebody. —- text = input() def uppercase_decorator(func): def wrapper(func): func.upper() #your code goes here return wrapper @uppercase_decorator def display_text(text): return(text) print(display_text(text))
3 ответов
+ 2
I see people doing the same mistake. Now i wonder why are you all jumping to decorator functions using (@) if you can't understand how it's actually implemented.
You should pass argument name(any random name ) to wrapper function instead of the function name(func is the display_text function name).
Your uppercase_decorator function should look like this,
def uppercase_decorator(func) :
def wrapper(t):
func(t).upper()
return wrapper
+ 1
Taka use return keyword at line no 5. to return func.upper() returned string.
https://code.sololearn.com/cEYet7syAU9e/?ref=app
0
Finally, I've got it!
Thanks guys!