在Python中,是否有可能从Bar本身获取包含另一个对象Bar的对象,比如说Foo?这是我的意思的一个例子
class Foo(object):
def __init__(self):
self.bar = Bar()
self.text = "Hello World"
class Bar(object):
def __init__(self):
self.newText = foo.text #This is what I want to do,
#access the properties of the container object
foo = Foo()
Run Code Online (Sandbox Code Playgroud)
这可能吗?谢谢!