Created
September 11, 2013 10:31
-
-
Save yuuichi-fujioka/6521891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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