CertGrid CertGrid
Concepts·Certified Associate Python Programmer

Python Multiple Inheritance and MRO

The other half of PCAP objective 4.5. A class may have several parents, and the method resolution order decides which one wins. The order is left to right and depth-limited in a specific way, super() follows it rather than jumping to a parent, and some inheritance orders are impossible and rejected at class-creation time. Every claim on this page is printed from __mro__ rather than reasoned about.

Object-Oriented Python Guide 19 of 25 Advanced

Python 3 uses C3 linearisation for the MRO, as Python 2.3 onwards did for new-style classes. Old-style classes had a simpler depth-first order and no longer exist.

One machine, and any shell with Python 3 will do - these exams test the language, not a distribution.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSPython 3.14.4 - the only machine this path needs2 Core4 GB50 GB

This guide includes

Use this for the multiple-inheritance half, the hardest material on PCAP. This matters because the order you list the bases decides which method wins - and super follows the resolution order rather than the parent you expect.

Before you start

  1. Two parents, and the order decides

  2. The diamond

  3. The diamond where only C defines the method

  4. super follows the MRO, not the parent

  5. An inheritance order Python refuses

  6. Every class ends at object

  7. A mixin, which is what multiple inheritance is really for

  8. What the exam does with this objective

Official sources