Skip to content

Instantly share code, notes, and snippets.

@inoshiro
Last active December 18, 2015 11:59
Show Gist options
  • Save inoshiro/5779548 to your computer and use it in GitHub Desktop.
Save inoshiro/5779548 to your computer and use it in GitHub Desktop.
In [1]: def deco(arg):
...: def wrapper(func):
...: def _wrapper():
...: return func(arg)
...: return _wrapper
...: return wrapper
...:
In [2]: @deco("ham")
...: def spam(egg):
...: print egg
...:
In [3]: spam()
ham
In [1]: def deco(func):
...: def wrap():
...: return func
...: wrap.hoge = "hoge"
...: return wrap
...:
In [2]: @deco
...: def hoge():
...: print hoge.hoge
...:
In [3]: h = hoge()
In [4]: h()
hoge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment