FREE Python, inside out LESSON · Python, inside out
Names point; objects behave
Identity, type, value, and protocol
Assignment binds a name to an object.
Python variables are names in namespaces, not boxes with fixed machine types. Objects carry identity, type, and value; mutability determines whether an operation changes an existing object or produces another. Multiple names can reference one mutable object, so local-looking updates may be observable elsewhere. Protocols such as iteration, context management, and attribute access let types participate in syntax through defined methods.
Draw the reference graph before blaming “pass by reference” or “pass by value.”
Convenient syntax can hide protocol calls.
A `for` loop drives the iterator protocol; `with` enters and exits a context; attribute access can invoke descriptors; operators dispatch special methods. This is powerful, but it means a seemingly small expression may allocate, execute user code, block, or raise. Use the data model to predict behavior before reaching for folklore.
Python is dynamic, not lawless: the protocols are explicit even when the syntax is compact.