title: Python - removing copy paste code in subclasses
body: <p>I have two classes <code>Z1</code> and <code>Z0</code> in my legacy code which are basically a copy paste. They both contain functions <code>f1() ... f6()</code> which are similar and function <code>f7()</code> in which they differ in string. <code>Class Z1</code> contains <code>string</code> "Z1" while <code>Z0</code> contains <code>string</code> "Z0" in <code>function f7()</code>.</p>
  
  <p>The classes have the following inheritance hierarchy:</p>
  
  <pre><code>class Z1(Y1)
  class Y1(D)
  class D(B)
  
  
  class Z2(Y2)
  class Y2(B)
  
  
  Z1 -&gt; Y1 -&gt; D -&gt; B
  Z2 -&gt; Y2 ------&gt; B
  </code></pre>
  
  <p>What is the best way to get rid off this copy paste code in Python?</p>