title: Get the type of the super class in Python 3
body: <p>I have a base class with two classes that are derived from it. I want the methods of the base classes to behave differently depending on whether the arguments are of the same type as the derived class, or only instances of the base class but a different type. This is the current implementation:</p>
  
  <pre><code>class MyBase:
      def __init__(self, foo: int):
          self.foo = foo 
  
      def __eq__(self, other):
          return self.foo == other.foo 
  
  
  class MyDerived_1(MyBase):
      def __init__(self, foo: int, bar: int):
          super().__init__(foo)
          self.bar = bar
  
  
  class MyDerived_2(MyBase):
      def __init__(self, foo: int, bar: int):
          super().__init__(foo)
          self.bar = bar 
  
      def __eq__(self, other):
          if type(other) == type(self):
              return self.bar == other.bar 
          elif isinstance(other, MyBase):
              return super().__eq__(other)
          else:
              return False
  </code></pre>
  
  <p>In the fourth last line I have to reference MyBase explicitly. Perhaps this is fine but my understanding is that a main point of the "super" keyword is that it should allow you to change the base class without having to re-write anything in the class. So I.e. a potential issue with this solution is that if MyBase is changed then <strong>init</strong> will be fine because it calls "super", but <strong>eq</strong> will not update its behaviour.</p>
  
  <p>So I attempted replacing "MyBase" with "type(super)" or "type(super())", but these do not reference the super class, they reference the class of the object "super".</p>
  
  <p>Note that this questions differs from:</p>
  
  <p><a href="https://stackoverflow.com/questions/10091957/get-parent-class-name">Get parent class name?</a>
  <a href="https://stackoverflow.com/questions/3589311/get-defining-class-of-unbound-method-object-in-python-3/25959545#25959545">Get defining class of unbound method object in Python 3</a>
  etc.</p>
  
  <p>Because they are looking for the parent classes once the object has been initialised.</p>
  
  <p>I guess that I should be able to find the super class by running up the MRO. But this seems like a bad solution given that I'm not looking for the whole inheritance tree, I just want to know the type of the super class.</p>
  
  <p>Is there a way to pull that information out of "super"?</p>