title: How to override in multiple classes without code duplication (Python)
body: <p>I am having a parent class <code>A</code> with few classes inheriting from it (<code>B</code>,<code>C</code>,...).</p>
  <p>I have some function <code>is_class_A</code> that is implemented in <code>A</code>, and I want to override it in <code>B</code> and <code>C</code> in the same way.</p>
  <p>Let say:</p>
  <pre><code>class A:
      def is_class_A():
          print(&quot;We are in class A&quot;)
  
  class B(A):
      def is_class_A():
          print(&quot;Nope&quot;)
  
  class C(A):
      def is_class_A():
          print(&quot;Nope&quot;)
  </code></pre>
  <p>Take in mind both functions that implement in class <code>A</code> and in the others, are long, and more complicate.</p>
  <p>2 solutions I came in my mind to avoid the duplication in <code>B</code>, <code>C</code> implementation:</p>
  <p>Using in class <code>C</code>:</p>
  <pre><code>def is_class_A():
      return B.is_class_A()
  </code></pre>
  <p>I am not sure how this will be functional, because an object of <code>C</code> is not an object of <code>B</code>. And I don't pass here any <code>self</code>, so I don't see how this will work, maybe something similar can?</p>
  <p>Next solution is using another heritage:</p>
  <pre><code>class C(B)
  </code></pre>
  <p>This won't work always, since not always possible (if they have different attributes) and might not fit the design purpose.</p>
  <p>My best attempt so far is to use another class:</p>
  <pre><code>class BC(A):
      def is_class_A():
          print(&quot;Nope&quot;)
  
  class B(BC):
      pass
  
  class C(BC):
      pass
  </code></pre>
  <p>What do you think? Some more ideas? Maybe something more technical that won't involve with the program design?</p>
  <p>Thanks.</p>