使用所有定义的装饰器在python中输入和离开定义时记录消息

时间:2017-08-17 22:28:26

标签: python-3.x

我无法在以下代码段中打印from functools import wraps def notification(func): @wraps(func) def with_logging(*args, **kwargs): print("Entering definition : " + func.__name__) print("Arguments passed : {0} {1}".format(args,kwargs)) d = func(*args, **kwargs) print("Leaving definition : " + func._name_) return d return d return with_logging @notification def addition_func(x): """""" return x result = addition_func(4) print(result)

Garage

0 个答案:

没有答案