Skip to content

Instantly share code, notes, and snippets.

@addisaden
Created January 13, 2014 21:15
Show Gist options
  • Save addisaden/8408313 to your computer and use it in GitHub Desktop.
Save addisaden/8408313 to your computer and use it in GitHub Desktop.
def a_simple_decorator(f):
def a_logger_for_f(*args, **hashs):
print("Logger called")
result = f(*args, **hashs)
print("The result is: {}".format(result))
return result
return a_logger_for_f
@a_simple_decorator
def a_simple_method(a, b):
return (a, b, a+b, a-b, a*b)
a_simple_method(2, 3)
a_simple_method(b=3, a=2)
# Logger called
# The result is: (2, 3, 5, -1, 6)
# Logger called
# The result is: (2, 3, 5, -1, 6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment