import functools def log(option):
def dec(func):
def swapper(*arg, **karg):
functools.update_wrapper(swapper, func)
opt = format(option,"^7")
print '['+opt+"] enter",func.__name__
res = func(*arg, **karg)
print '['+opt+'] exit',func.__name__
return res
return swapper
return dec