THE ATHENA LIBRARY
Python for Intermediate Learners
Daniel Haile textbook
Chapter 5 · Properties and Privacy
We are all consenting adults
Python has no private keyword. Instead, a leading underscore — self._balance — signals that an attribute is internal. Double underscores trigger name mangling, which discourages accidental access from subclasses.
The @property decorator offers encapsulation without ceremony. Callers write account.balance as if it were a plain attribute, while the class quietly validates or computes the value behind the scenes.
Encapsulation in Python is therefore a matter of convention and design rather than enforcement, but the goal is the same as in Java: protect invariants and present a clear public surface.
Fictional educational sample written for the Athena demo · Page 92 of 356.
50%saved