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