You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Today I am learning very new topic, whose name i never heard when I was learning python in college, and the name of the topic is Decorators, I understand that Functions are the first class objects in python. What I mean here is that they can be treated as a variable and one can pass them as an arguments to another function, or even return them as a return value.
import time
def timer_it(func):
def wrapper(*args, **kwargs):
start = time.time()
func(*args, **kwargs)
end = time.time()
duration_sec = end-start
print(f'{func.__name__} took {duration_sec} to execute')