Part 4 · Section 06

Single Inheritance

Inheritance lets you say that one class is a more specialized kind of another: a Square is a Rectangle, a Savings account is an Account. The child class gets everything the parent defines for free, and then changes or adds only what’s different. Single inheritance, where every class has exactly one parent, is the simplest and most common form, and understanding it well (especially which method runs and which object self is) is the foundation for everything else in object-oriented Python.

The section ends with __slots__, a way to give up the per-instance __dict__ in exchange for less memory and slightly faster attribute access, and with the rules for combining slots with inheritance.

In this section you’ll learn:

Lectures

  1. 01Single Inheritance✓
  2. 02The object Class✓
  3. 03Overriding✓
  4. 04Extending✓
  5. 05Delegating to Parent✓
  6. 06Slots✓
  7. 07Slots and Single Inheritance✓

Practice: quiz & exercises

12 quiz questions · 4 coding exercises

Go to practice →