inheritance

Class inheritance and method overriding, letting classes reuse and extend behavior from parents.

Python Encapsulation: Private, Protected & Name Mangling

Python encapsulation works on trust, not locks. A single underscore says “please leave this alone,” a double underscore makes the name harder to reach, and that is the whole system. No compiler stands guard. This post shows how public, protected, and private attributes really behave, what name mangling does, and the Pythonic @property pattern that gives you safe, validated access. “In Python, we’re all consenting adults here.” Alex Martelli, Python in a Nutshell Think of a shared office fridge. Your ... Read More

Python Inheritance: Single, Multi-level, Hierarchical

Python inheritance lets one class reuse the attributes and methods of another. This guide walks through single, multi-level, and hierarchical inheritance with tested examples, plus super(), method overriding, and when inheritance is the wrong tool. “An algorithm must be seen to be believed.” Donald Knuth, The Art of Computer Programming Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Intermediate | Reading Time: 14 minutes Think about a family recipe. Your grandmother has a base recipe for curry. ... Read More