The problem is here:
self.allShapes = self.allCircles + self.allSquares + self.allTriangles
When combining lists like this, the result is a copy of the lists of components. Therefore, when these lists are changed later, the concatenated list will not be changed. In this case, self.allCircles , etc. All are empty. So self.allShapes also an empty list; the for loop in ShapeSet.__str__ does not add anything to the ShapeList , so the result is an empty string.
One easy way to fix this would be to make the allShapes method that you call, and which returns a new concatenation of self.allCircles ... etc. every time he calls. Thus, allShapes always updated.
source share