class Foo(object):

    def __init__(self):
        self.text = 'Hello World'
self.bar = Bar(self)


class Bar(object):

    def __init__(self, parent):
        self.parent = parent
Getting container/parent object from within python