class TestClass(object):
def __init__(self):
super(TestClass, self).__init__()
def __getattr__(self, item):
def call(self, *args, **kwargs):
info = {
'called_name': item,
'args': args
}
print info
setattr(TestClass, item, call)
return getattr(self, item)
a = TestClass()
a.cnmd('hello world')
a.nmbs(1, 2, 3, '4')
上面这种写法在用python写rpc框架的时候很实用, 谁用谁清楚