inheritance

Class inheritance and method overriding, letting classes reuse and extend behavior from parents.

Python: Abstract Classes & Interfaces (ABC Module)

Learn the Python abstract class with the ABC (Abstract Base Class) module. Understand @abstractmethod, when to use abstract classes vs duck typing, and how to enforce method contracts across your class hierarchies. “A good design principle: always program to an interface, not an implementation.” Gang of Four, Design Patterns Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Intermediate | Reading Time: 12 minutes Prerequisites: Inheritance, Polymorphism A Python abstract class is a checklist that your subclasses are ... Read More

Python: Multiple Inheritance & MRO

Python multiple inheritance lets one class inherit from several parents at once. This guide explains the diamond problem, Method Resolution Order (MRO), C3 linearization, and how Python decides which method actually runs. “Everyone knows that debugging is twice as hard as writing a program in the first place.” Brian Kernighan, The Elements of Programming Style Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Intermediate | Reading Time: 13 minutes Prerequisites: Inheritance Here is the question that breaks ... Read More

Python: Polymorphism, Method Overriding & Duck Typing

Think about the power button on a TV remote, an AC remote, and a car key fob. You press the same button on each one, but a completely different thing happens every time. The TV turns on, the AC starts cooling, the car unlocks. Same action, different result depending on what you are pressing it on. That is Python polymorphism in one picture: one name, many behaviours. “If it walks like a duck and it quacks like a duck, then ... Read More