CertGrid CertGrid
Concepts·Certified Associate Python Programmer

Python Introspection and Class Attributes

PCAP objective 4.4 is discover the class structure, and it is a list of things you can ask an object about itself: __class__, __name__, __bases__, __mro__, __dict__, __doc__, plus isinstance, issubclass and the four *attr functions. Most of it is mechanical. Two details are not: type() and isinstance() disagree once inheritance is involved, and __doc__ is not inherited.

Object-Oriented Python Guide 17 of 25 Intermediate

__mro__ and __bases__ are unchanged in Python 3. Every class has them, because every class is a new-style class - see guide 19.

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 class-discovery objective, which is a list of things to know rather than a concept. This matters because __doc__ is the one attribute that is not inherited, and that is exactly what gets asked.

Before you start

  1. Asking an object what it is

  2. __doc__ is not inherited

  3. The two dictionaries

  4. isinstance and issubclass

  5. The four attribute functions

  6. dir on your own class

  7. What the exam does with this objective

Official sources