From 0ca9724ba4da9687b389ac14127cb0c2c8804937 Mon Sep 17 00:00:00 2001 From: Ricardo Estrada Date: Mon, 22 Jun 2020 23:58:52 -0500 Subject: [PATCH] decorator which notify the start and end of func --- challenge.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/challenge.py b/challenge.py index c69287d..e04b7ad 100644 --- a/challenge.py +++ b/challenge.py @@ -1,9 +1,13 @@ -import time +from time import strftime, localtime, time -def finish_date(): +def finish_date(func): # You have to code here!! - + def wrapper(*args, **kwargs): + print( strftime(f" inicio function {func.__name__} %d/%m/%Y %H:%M:%S", localtime(time()))) + func(*args, **kwargs) + print( strftime(f" finalizo la funcion {func.__name__} %d/%m/%Y %H:%M:%S", localtime(time()))) + return wrapper @finish_date def palindrome(string): @@ -13,7 +17,7 @@ def palindrome(string): @finish_date def long_function(): - for _ in range(1000000): + for _ in range(1000000000): pass