Discuss / Python / 再简单的代码也要亲手敲一遍

再简单的代码也要亲手敲一遍

Topic source

翁岚敏

#1 Created at ... [Delete] [Delete and Lock User]

import functools def log(text=''): def decorator(func): @functools.wraps(func) def wrapper(args,**kw): print('call begin') print('%s %s():'%(text,func.name)) ret = func(args,**kw) print('call end') return ret return wrapper return decorator

@log('execute') def now(): print('2015-3-25') now()


  • 1

Reply