Created
May 27, 2020 11:40
-
-
Save maxwellcc/2bab043195993049f3a692920a2d1a47 to your computer and use it in GitHub Desktop.
Exemplos de decoradores
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def timethis(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
start = time.time() | |
result = func(*args, **kwargs) | |
end = time.time() | |
print(func.__name__, end - start) | |
return result | |
return wrapper | |
@timethis | |
def countdown(n): | |
while n > 0: | |
n -= 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment