You must first create both objects, and then create an attribute in each of the objects, which will refer to the second object.
Then each of the objects can access this attribute when it needs a reference to the "partner".
class func(object): def check(self): print self.link a = func() b = func() a.link = b b.link = a print(a.check()) print(b) # Выведет: # <__main__.func object at 0x7fc9c3d3a050> # <__main__.func object at 0x7fc9c3d3a050> print(b.check()) print(a) # Выведет # <__main__.func object at 0x7fc9c3d29fd0> # <__main__.func object at 0x7fc9c3d29fd0>
As you can see, each of the objects really now has access to the second object.
And then you can do it like this :)
print(a.link.link.link.link.link.link.link.link.link) # Выведет # <__main__.func object at 0x7fc9c3d3a050>