import time
# Define o contador de funções decoradas:
decorated_functions = 0
# Definição do decorador:
def decorator( function) :
# Incrementa o contador:
decorated_functions += 1
# Inicializa o horário da última chamada:
last_call = None
# Define a função de retorno:
def wrapper( *args, **kwargs) :
# Exibe e atualiza o horário da última chamada:
print ( "Última chamada:" , last_call)
last_call = time .time ( )
# Chama a função decorada:
function( *args, **kwargs)
return wrapper
@ decorator
def foo( ) :
print ( "Foo executada" )
foo( )
aW1wb3J0IHRpbWUKCiMgRGVmaW5lIG8gY29udGFkb3IgZGUgZnVuw6fDtWVzIGRlY29yYWRhczoKZGVjb3JhdGVkX2Z1bmN0aW9ucyA9IDAKCiMgRGVmaW5pw6fDo28gZG8gZGVjb3JhZG9yOgpkZWYgZGVjb3JhdG9yKGZ1bmN0aW9uKToKCiAgICAjIEluY3JlbWVudGEgbyBjb250YWRvcjoKICAgIGRlY29yYXRlZF9mdW5jdGlvbnMgKz0gMQoKICAgICMgSW5pY2lhbGl6YSBvIGhvcsOhcmlvIGRhIMO6bHRpbWEgY2hhbWFkYToKICAgIGxhc3RfY2FsbCA9IE5vbmUKCiAgICAjIERlZmluZSBhIGZ1bsOnw6NvIGRlIHJldG9ybm86CiAgICBkZWYgd3JhcHBlcigqYXJncywgKiprd2FyZ3MpOgoKICAgICAgICAjIEV4aWJlIGUgYXR1YWxpemEgbyBob3LDoXJpbyBkYSDDumx0aW1hIGNoYW1hZGE6CiAgICAgICAgcHJpbnQoIsOabHRpbWEgY2hhbWFkYToiLCBsYXN0X2NhbGwpCiAgICAgICAgbGFzdF9jYWxsID0gdGltZS50aW1lKCkKCiAgICAgICAgIyBDaGFtYSBhIGZ1bsOnw6NvIGRlY29yYWRhOgogICAgICAgIGZ1bmN0aW9uKCphcmdzLCAqKmt3YXJncykKCiAgICByZXR1cm4gd3JhcHBlcgogICAgCkBkZWNvcmF0b3IKZGVmIGZvbygpOgogICAgcHJpbnQoIkZvbyBleGVjdXRhZGEiKQogCmZvbygp