Introduction to Python ProgrammingXYZ Homework Edition

⇩ Download ▾

13.4 Hierarchical inheritance

Learning objectives

By the end of this section you should be able to

  • Label relationships between classes as types of inheritance.
  • Construct classes that form hierarchical inheritance.

Hierarchical inheritance basics

Hierarchical inheritance is a type of inheritance in which multiple classes inherit from a single superclass. Multilevel inheritance is a type of inheritance in which a subclass becomes the superclass for another class. Combining hierarchical and multilevel inheritance creates a tree-like organization of classes.

Implementing hierarchical inheritance

Multiple classes can inherit from a single class by simply including the superclass name in each subclass definition.

Adapted from Introduction to Python Programming by OpenStax (openstax.org), licensed under CC BY-NC-SA 4.0. Changes were made. License: CC-BY-NC-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or any other accessibility standard. Every page is built against an automated accessibility gate, and our target for the published editions is WCAG 2.2 Level AA. If something is unusable, please tell us.