Skip to content

Instantly share code, notes, and snippets.

@herberthamaral
Created November 10, 2011 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herberthamaral/1355886 to your computer and use it in GitHub Desktop.
Save herberthamaral/1355886 to your computer and use it in GitHub Desktop.
def meu_decorator(f):
def novo_f():
print 'iniciando f'
print 'finalizando f'
return novo_f
@meu_decorator
def minhafuncao():
print 'dentro da funcao'
minhafuncao()
#o exemplo a seguir funciona da mesma forma que o anterior:
print '-'*30
def meu_decorator(f):
def novo_f():
print 'iniciando f'
print 'finalizando f'
return novo_f
def minhafuncao():
print 'dentro da funcao'
minhafuncao = meu_decorator(minhafuncao)
minhafuncao()
@deploytoprod
Copy link

Bota um "f()" entre a linha 19 e 20 :)

@herberthamaral
Copy link
Author

ah sim, eu fiz esse exemplo pra demonstrar que nem sempre a função decorada precisa ser chamada, mas valeu pela observação!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment