def log(func): ... @functools.wraps(func) ... def wrapper(*args,**kw): ... print('begin call %s():' %func.__name__) ... function = func(*args,**kw) ... print('end call %s():' %func.__name__) ... return function ... return wrapper ... >>> @log ... def now(): ... print('2015-09-16') ... >>> now() begin call now(): 2015-09-16 end call now():
Sign in to make a reply
gannyee