1. From Part One to Language Protocols

In Part 1, we established the foundation of Python's data model: objects possess identity, type, and value; names hold references to those objects; mutability determines what changes can occur without replacing the object; and containers store references to other objects.

Now we advance another layer.

The type of an object does not merely determine what values it can represent. It also determines which operations that object supports: whether it has a size, whether it can be traversed, compared, indexed, called as a function, used in a with statement, and so forth (PYTHON SOFTWARE FOUNDATION, 2026a).

This is where special methods come in.