Skip to content

Instantly share code, notes, and snippets.

@maxwellcc
Created May 27, 2020 11:40
Show Gist options
  • Save maxwellcc/2bab043195993049f3a692920a2d1a47 to your computer and use it in GitHub Desktop.
Save maxwellcc/2bab043195993049f3a692920a2d1a47 to your computer and use it in GitHub Desktop.
Exemplos de decoradores
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