Skip to content

Instantly share code, notes, and snippets.

@paulosuzart
Created June 18, 2010 21:02
Show Gist options
  • Save paulosuzart/444229 to your computer and use it in GitHub Desktop.
Save paulosuzart/444229 to your computer and use it in GitHub Desktop.
import functools
def printAround(key):
"""
snipet to remember prepare cached invocations in memcached.
"""
def decorator(f):
@functools.wraps(f)
def new_f(*args):
print 'entering', f.__name__
print 'key ', key
f(*args)
print 'done'
return new_f
return decorator
@printAround('ops')
def hi(name):
print ('hi %s' % name)
hi('paul')
"""
prints:
entering hi
key ops
hi paul
done
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment