title: Chain-calling parent initialisers in python
body: <p>Consider this - a base class A, class B inheriting from A, class C inheriting from B. What is a generic way to call a parent class initialiser in an initialiser? If this still sounds too vague, here's some code.</p>
  
  <pre><code>class A(object):
      def __init__(self):
          print "Initialiser A was called"
  
  class B(A):
      def __init__(self):
          super(B,self).__init__()
          print "Initialiser B was called"
  
  class C(B):
      def __init__(self):
          super(C,self).__init__()
          print "Initialiser C was called"
  
  c = C()
  </code></pre>
  
  <p>This is how I do it now. But it still seems a bit too non-generic - you still must pass a correct type by hand.</p>
  
  <p>Now, I've tried using <code>self.__class__</code> as a first argument to super(), but, obviously it doesn't work - if you put it in the initialiser for C - fair enough, B's initialiser gets called. If you do the same in B, "self" still points to an instance of C so you end up calling B's initialiser again (this ends in an infinite recursion).</p>
  
  <p>There is no need to think about diamond inheritance for now, I am just interested in solving this specific problem.</p>