OOP

Object-oriented programming concepts: classes, objects, inheritance, encapsulation, and polymorphism.

Python: Closures, Lexical Scoping & Practical Uses

A Python closure is a function that remembers variables from its enclosing scope even after that scope is gone. This post shows how that memory works under the hood: lexical scoping, cell objects, the nonlocal keyword, and why every decorator you will ever write is built on a closure. “The key to understanding complicated things is knowing what not to look at.” Peter Norvig, PAIP Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Intermediate | Reading Time: ... Read More

Python: Iterators and the Iterator Protocol

Ask Python to loop over a list, a file, or a dictionary, and it plays the same trick every time: it asks the object for a Python iterator, then pulls values one by one until StopIteration says stop. This post unpacks that protocol, __iter__ and __next__ included, and shows you how to build a custom iterator of your own. “Simple is better than complex. Complex is better than complicated.” Tim Peters, The Zen of Python (PEP 20) Last Updated: July ... Read More

Python: Packages, __init__.py, Relative Imports

One file called __init__.py is all that separates a random folder of scripts from a real, importable library. Python packages are how projects scale past a handful of modules: group related files in a directory, add that one file, and the whole folder imports as a unit. This guide covers creating packages, relative imports, __all__, and layouts that stay clean as a project grows. “The structure of a software system reflects the social structure of the organization that built it.” ... Read More