title: python multiple inheritance: avoid calling the constructors twice in diamond shape
body: <p>Consider the following code:</p>
  
  <pre><code>class A(object):
      def __init__(self):
          print("A.__init__")
          super(A, self).__init__()          # 1
          print("A.__init__ finished")
  
  class B(A):
      def __init__(self):
          print("B.__init__")
          super(B, self).__init__()          # 2
          print("B.__init__ finished")
  
  class C(A):
      def __init__(self):
          print("C.__init__")
          super(C, self).__init__()
          print("C.__init__ finished")
  
  class D(B, C):
      def __init__(self):
          print("D.__init__")
          print("Initializing B")
          B.__init__(self)                   # 3
          print("B initialized")
          print("Initializing C")
          C.__init__(self)                   # 4
          print("C initialized")
          print("D.__init__ finished")
  
  D()
  
  # D.__init__
  # Initializing B
  # B.__init__
  # C.__init__
  # A.__init__
  # A.__init__ finished
  # C.__init__ finished
  # B.__init__ finished
  # B initialized
  # Initializing C
  # C.__init__
  # A.__init__
  # A.__init__ finished
  # C.__init__ finished
  # C initialized
  # D.__init__ finished
  </code></pre>
  
  <p>As far as I understand, the algorithm is as follows:</p>
  
  <pre><code>D.__init__ at (3) -&gt; B.__init__ -&gt; 
  -&gt; super().__init__ -&gt; (super of self.__class__).__init__ -&gt;
  -&gt; C.__init__ (# why C?) -&gt; super().__init__ -&gt; 
  -&gt; A.__init__
  
  D.__init__ at (4) -&gt; C.__init__ -&gt;
  -&gt; super().__init__ -&gt; 
  -&gt; A.__init__
  </code></pre>
  
  <p>Actually there are three questions:<br>
  1. Why <code>super().__init__()</code> call in <code>B.__init__</code> (at 2) calls <code>C.__init__</code> when <code>self</code> is an instance of <code>D</code>?<br>
  2. How to avoid calling <code>C.__init__</code> and <code>A.__init__</code> twice in this case?<br>
  2.1 What is the right way to initialize all the classes the current class inherits from?</p>