动态修改类的属性
摘要:
from __future__ import nested_scopesimport newdef enhance_method(klass, method_name, replacement): '替换方法的函数' method = getattr(klass, method_name) setattr(klass, method_name, new.instancemethod( lambda *args, **kwds: replacement(method, *args, **kwds), None, klass))def method_logger(old_metho 阅读全文
posted @ 2013-06-08 17:27 Odoo在中国 阅读(452) 评论(0) 推荐(0) 编辑