-
-
Save maxwellamaral/b6f935dde841ab63722b35169bb383b0 to your computer and use it in GitHub Desktop.
Exemplos de decoradores
This file contains 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