Composition over inheritance (or composite reuse principle) in object-oriented programming (OOP) is the principle that classes should favour polymorphic behaviour and code reuse by their composition (by containing instances of other classes that implement the desired functionality) over inheritance from a base or parent class.
import tkinter as tk
class MyClass(tk.Tk):
''' class using super '''
def __init__(self):
super().__init__()
self.title('class using super')
self.mainloop()
return
class MyOtherClass:
''' class that does not use super '''
def __init__(self):
self.win = tk.Tk()
self.win.title('class NOT using super')
self.win.mainloop()
return
# main guard idiom
if __name__=='__main__':
app_1 = MyClass()
app_2 = MyOtherClass()
I simple terms, if the user wants to extend an existing class, then it should inherit. If the user wants to use the class then it should compose. In the example above, composing is clearer for the user.