Container / Elternobjekt aus Python holen

In Python ist es möglich, das Objekt, sagen wir "Foo", dass ein anderes Objekt enthält, an der Bar in der Bar selbst? Hier ist ein Beispiel, was ich meine

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()

Ist das möglich? Danke!

InformationsquelleAutor der Frage Michael McClenaghan | 2012-05-28

Schreibe einen Kommentar