Skip to content

Instantly share code, notes, and snippets.

@yuuichi-fujioka
Created September 11, 2013 10:31
Show Gist options
  • Save yuuichi-fujioka/6521891 to your computer and use it in GitHub Desktop.
Save yuuichi-fujioka/6521891 to your computer and use it in GitHub Desktop.
# define decorator
def my_deco(*arg, **kwargs):
def _(func):
func.__dict__.setdefault('foo', (arg, kwargs))
return func
return _
# make decorated function
@my_deco(alice='brother')
def echo(msg):
print msg
# test
assert(echo.__dict__['foo'] == ((), {'alice': 'brother'}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment