I dont understand why i cant acces the name of the inner function decorated with the outer function?
it raise this error:
NameError: name ‘inner_text_function’ is not defined
def outer_wrapper_function(func) -> str:
print(f"This is the outer function: named -|{outer_wrapper_function.__name__}|- and located at -|{outer_wrapper_function}")
print(f" |-->This is the inner function: named -|{func.__name__}|- and located at -|{func}")
textwraped: str = func().upper()
print(f"Text wrapped: {textwraped}")
return textwraped
#Passing a function as argument var_1:
def inner_text_function() -> str:
print(f" |-->This is the inner function: named -|{inner_text_function.__name__}|- and located at -|{inner_text_function}")
textwrap = "this is some texts to be wrapped ****"
print(f"Text un-wrapped: {textwrap}")
return textwrap
text_function = outer_wrapper_function(func = inner_text_function)
print(text_function)
#Now printing the inner_text_function not decorated with @ suntax:
text_function = inner_text_function
print(text_function)
#Passing a function as argument var_2:
@outer_wrapper_function
def inner_text_function(text = "NOW") -> str:
print(f" |-->This is the inner function: named -|{inner_text_function.__name__}|- and located at -|{inner_text_function}")
textwrap = "this is some texts to be wrapped ****".replace('****', text)
print(f"Text un-wrapped: {textwrap}")
return textwrap
#Now printing the inner_text_function alredy decorated with @ suntax:
text_function = inner_text_function
print(text_function, type(inner_text_function))
#it work if i pass the inner function as the var_1 but it raise that error with te var_2. why?