0
What is the use of "wrap" function?
Why does the following code come out with an "Nonetype"error? def decor(func): print("============") func() print("============") def print_text(): print("Hello world!") print_text = decor(print_text) print_text();
1 Answer
+ 1
print_text == None, because decor() returns None.
try:
def decor(f):
#....
@decor
def print_text():
#...
print_text()
or:
def decor(func):
def s():
print('....')
func()
print('....')
return s
def print_text():
#....
print_text=decor(print_text)
print_text()