CertGrid CertGrid
Concepts·Certified Associate Python Programmer

Python Constructors

PCAP objective 4.6 is construct and initialize objects. `__init__` runs automatically when an instance is created, receives the instance as `self`, and has two rules that are examined directly: the arguments must match like any function's, and it may not return anything but `None`. The mutable-default trap from the functions track reappears here in its most damaging form.

Object-Oriented Python Guide 13 of 25 Intermediate

Written against the versions above. `__init__` is unchanged in Python 3. `__new__` also exists and runs before it; neither exam examines `__new__`, and you will not need it.

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

Before you start

  1. __init__ runs when the object is created

  2. The arguments must match

  3. __init__ may not return a value

  4. A class with no __init__ at all

  5. The mutable default, in its worst form

  6. The fix

  7. Calling a parent constructor

  8. What the exam does with this objective

Official sources