Skip to content

Instantly share code, notes, and snippets.

@bveliqi
Created September 14, 2013 09:42
Show Gist options
  • Save bveliqi/6560570 to your computer and use it in GitHub Desktop.
Save bveliqi/6560570 to your computer and use it in GitHub Desktop.
A simple python decorator.
def logcall(f):
def wrapper(*a, **opts):
print('calling ' + f.__name__)
f(*a, **opts)
print('called ' + f.__name__)
return wrapper
@logcall
def square(x):
print 'result: ' + str(x * x)
return x * x
square(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment