摘要: 除了可以用在方法上,其实python的装饰器也可以作用于类上,在不改变类的情况下,给类增加一些额外的功能. # 下面是一个重写了特殊方法 __getattribute__ 的类装饰器,可以打印日志: def log_getattribute(cls): origin_getattribute=cls 阅读全文
posted @ 2020-06-16 15:53 Mars.wang 阅读(911) 评论(0) 推荐(0) 编辑