Automatic commit performed through alias...

This commit is contained in:
Shaun Setlock
2020-04-14 21:01:53 -04:00
parent efac2d7cc8
commit b9f031cc5c
3 changed files with 22 additions and 15 deletions

20
problems/decorators.py Normal file
View File

@@ -0,0 +1,20 @@
"""
Collection of decorators that could be helpful while solving problems.
"""
# Function decorator which calculates the time required to execute a function.
def function_timer(passed_f):
def inner_f(*args, **kwargs):
import time
t1 = time.time()
value = passed_f(*args, **kwargs)
t2 = time.time()
t3 = t2 - t1
print("The function {} ran for {:4f} seconds... ".format(passed_f.__name__,t3))
return value
return inner_f