title: Using a class' __new__ method as a Factory: __init__ gets called twice
body: <p>I encountered a strange bug in python where using the <code>__new__</code> method of a class as a factory would lead to the <code>__init__</code> method of the instantiated class to be called twice.</p>
  
  <p>The idea was originally to use the <code>__new__</code> method of the mother class to return a specific instance of one of her children depending on the parameters that are passed, without having to declare a factory function outside of the class.</p>
  
  <p>I know that using a factory function would be the best design-pattern to use here, but changing the design pattern at this point of the project would be costly. My question hence is: is there a way to avoid the double call to <code>__init__</code> and get only a single call to <code>__init__</code> in such a schema ?</p>
  
  <pre><code>class Shape(object):
      def __new__(cls, desc):
          if cls is Shape:
              if desc == 'big':   return Rectangle(desc)
              if desc == 'small': return Triangle(desc)
          else:
              return super(Shape, cls).__new__(cls, desc)
  
      def __init__(self, desc):
          print "init called"
          self.desc = desc
  
  class Triangle(Shape):
      @property
      def number_of_edges(self): return 3
  
  class Rectangle(Shape):
      @property
      def number_of_edges(self): return 4
  
  instance = Shape('small')
  print instance.number_of_edges
  
  &gt;&gt;&gt; init called
  &gt;&gt;&gt; init called
  &gt;&gt;&gt; 3
  </code></pre>
  
  <p>Any help greatly appreciated.</p>