Skip to content

Instantly share code, notes, and snippets.

@sidchilling
Created April 29, 2013 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidchilling/5480081 to your computer and use it in GitHub Desktop.
Save sidchilling/5480081 to your computer and use it in GitHub Desktop.
How to use the decorator package to write decorators
from decorator import decorator
def my_decorator_wrapper(func, first_name, last_name):
print 'You passed me the args: %s, %s' %(first_name, last_name)
return func(first_name, last_name)
my_decorator_wrapper = decorator(my_decorator_wrapper)
@my_decorator_wrapper
def decorated_function(first_name, last_name):
print 'My name is %s %s' %(first_name, last_name)
decorated_function('Luna', 'Lovegood')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment