Я пытаюсь выучить python и не знаю, почему последнее утверждение приводит к бесконечному рекурсивному вызову. Может кто-нибудь объяснить
class Container:
tag = 'container'
children = []
def add(self,child):
self.children.append(child)
def __str__(self):
result = '<'+self.tag+'>'
for child in self.children:
result += str(child)
result += '<'+self.tag+'/>'
return result
class SubContainer(Container):
tag = 'sub'
c = Container()
d = SubContainer()
c.add(d)
print(c)