Skip to main content
Module 7 · Lesson 2 of 426/36 in the course~16 min
Module lessons (2/4)

Inheritance

Lesson preview5 hands-on exercises readyPython Course · Module 7 — Classes and modules

Subclasses, super(), method overrides, isinstance, and foundational C3 MRO lookup.

What you'll learn in this lesson

  • Create specialized subclasses with class Child(Parent): by reusing methods and shared state.
  • Safely delegate initialization to the parent with super().__init__(...).
  • Override methods while maintaining polymorphic compatibility and test types with isinstance() and issubclass().
  • Read MRO (C3 linearization) resolution order in multiple inheritance.

Overview

Inheritance models an "is-a" (is-a) relationship: a subclass inherits the superclass's methods and attributes, can add new ones, and can redefine (override) existing ones to specialize the behavior.

When you search for a method on a subclass, Python follows a precise ordered list called MRO (Method Resolution Order): it scrolls through the hierarchy from left to right without ever visiting the same shared class twice (C3 linearization algorithm).

Sections covered in this lesson

  1. 11. Subclassing, overriding and polymorphism
  2. 22. Extend the parent with super()
  3. 33. Test the hierarchy with isinstance and issubclass
  4. 44. Multiple inheritance, mixins and .mro()
  5. 5Check for understanding
  6. 6Test yourself
Pro Lesson · Module 7 — Classes and modules

Unlock "Inheritance" and the full Python Course curriculum

Subclasses, super(), method overrides, isinstance, and foundational C3 MRO lookup.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Python Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.