Merge decorator function as class
- by SyetemHog
How to make this merge function as class decorator?
def merge(*arg, **kwarg): # get decorator args & kwargs
def func(f):
def tmp(*args, **kwargs): # get function args & kwargs
kwargs.update(kwarg) # merge two dictionaries
return f(*args, **kwargs) # return merged data
return tmp
return func
Usage:
@other_decorator # return *args and **kwarg
@merge(list=['one','two','three']) # need to merge with @other_decorator
def test(*a, **k): # get merged args and kwargs
print 'args:', a
print 'kwargs:', k