def decorator(function):
def wrapper(*args, **kwargs):
print("Antes de chamar a função", function.__name__)
function(*args, **kwargs)
print("Depois de chamar a função", function.__name__)
return wrapper
@decorator
def foo(name):
print(name)
@decorator
def bar(number):
print(2*number)
foo("Anderson")
bar(2)
ZGVmIGRlY29yYXRvcihmdW5jdGlvbik6CiAgICBkZWYgd3JhcHBlcigqYXJncywgKiprd2FyZ3MpOgogICAgICAgIHByaW50KCJBbnRlcyBkZSBjaGFtYXIgYSBmdW7Dp8OjbyIsIGZ1bmN0aW9uLl9fbmFtZV9fKQogICAgICAgIGZ1bmN0aW9uKCphcmdzLCAqKmt3YXJncykKICAgICAgICBwcmludCgiRGVwb2lzIGRlIGNoYW1hciBhIGZ1bsOnw6NvIiwgZnVuY3Rpb24uX19uYW1lX18pCiAgICByZXR1cm4gd3JhcHBlcgoKQGRlY29yYXRvcgpkZWYgZm9vKG5hbWUpOgogICAgcHJpbnQobmFtZSkKCkBkZWNvcmF0b3IKZGVmIGJhcihudW1iZXIpOgogICAgcHJpbnQoMipudW1iZXIpCgpmb28oIkFuZGVyc29uIikKYmFyKDIp