Using a class’ __new__ method as a Factory: __init__ gets called twice
When you construct an object Python calls its __new__ method to create the object then calls __init__ on the object that is returned. When you create the object from inside __new__ by calling Triangle() that will result in further calls to __new__ and __init__. What you should do is: class Shape(object): def __new__(cls, desc): if … Read more