Python Programming

Inheritance and Shared Interfaces

4:13

Plays from YouTube. Watch on YouTube

When should one Python class inherit from another and when is it a mistake?

Meet inheritance, method overriding and polymorphism through a shared payment interface.

We start with base classes and subclass definitions, then examine method dispatch and substitutability.

From there, we use super, discuss Python's object superclass and compare inheritance with composition.

Finally, we check representation invariants and the behavioral promises that subclasses must preserve.

The big idea: sharing an interface matters more than sharing implementation code.

Object-oriented programming explained visually, one concept at a time.