怎样得到一个方法的caller对象
class C:
str = {}
def __init__(self):
self.d = D()
self.name = "sophia tang"
def f(self):
self.d.f1(self.str)
print "self.str==",self.str
class D:
def f1(self, str):
str['a'] = 'hello'
self.f2(str)
import inspect
caller = inspect.stack()[1][0].f_locals['self']
print caller.name
def f2(self, str):
str['b'] = "sophia"