I have the following decorated function:
import time
def logging_time(func):
"""Decorator that logs time"""
def logger():
"""Function that logs time"""
start = time.time()
func()
print(f"Calling {func.__name__}: {time.time() - start:.5f}")
return logger
@logging_time
def calculate_sum():
return sum(range(10000))
When I run calculate_sum() I get Calling calculate_sum: 0.00043 which is the output of the @logging_time.
How can I also retrieve the return value of the calculate_sum function as well ? Why isnt the sum(range(10000)) returned as well ?