Concepts·Certified Associate Python Programmer
Python Instance and Class Variables
This is the most asked subject in PCAP's 34% object-oriented section, and it comes down to one rule: **reading an attribute searches the instance and then the class; assigning one always writes to the instance.** Everything surprising follows - the list shared between every instance, and the counter that increments to 1 three times over.
Object-Oriented Python Guide 15 of 25 Intermediate
- Python3.14.4
- OSUbuntu 26.04 LTS
- pip25.1.1
- TimeAbout 17 min
- Reviewed23 August 2026
Written against the versions above. Unchanged in Python 3. The attribute lookup order described here is the same mechanism that makes inheritance work - see {{guide:inheritance-and-overriding}}.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Python 3.14.4 - the only machine this path needs | 2 Core | 4 GB | 50 GB |
Before you start
-
Where each variable lives
-
Assigning through an instance creates an instance variable
-
The trap: a mutable class variable
-
The fix
-
What a class variable is actually for
-
The counter that does not count
-
The rule, in one line
-
What the exam does with this objective