hi, im a beginner. in the below code, why is the resultValue None?
def wrapper(func):
def wrapPrintAndReturn():
print('im inside wrapper')
func()
return wrapPrintAndReturn
@wrapper
def printAndReturn():
print('im inside printAndReturn')
return 'returned from printAndReturn'
returnValue = printAndReturn()
print(returnValue) #None```
but when i instead do `return func()` in `wrapPrintAndReturn`, the output is what i expect i.e. returnValue prints 'returned from printAndReturn'
```py
def wrapper(func):
def wrapPrintAndReturn():
print('im inside wrapper')
return func()
return wrapPrintAndReturn
@wrapper
def printAndReturn():
print('im inside printAndReturn')
return 'returned from printAndReturn'
returnValue = printAndReturn()
print(returnValue)
can you help me understand the working? as i understand in the first code, printAndReturn functions gets overwritten as the function wrapPrintAndReturn which is returned by wrapper, so the func gets called which is the original printAndReturn, im thinking thereby printAndReturn should be returning the string 'returned from printAndReturn' which does not happen. why?