liveBook · Manning

Attribute lookup

Attribute lookup is Python's runtime process for resolving a named attribute through an object's instance, class, inheritance hierarchy, and base objects.

How 2 Manning books explain it

Python Workout: 50 ten-minute exercises

Attribute lookup is the runtime process Python uses to resolve a named attribute accessed through an object.

How it is used
Resolves named attributes on objects and explains how instance method calls reach definitions stored on classes.
How deep it goes
Explains the ICPO search order and method retrieval, while stopping before detailed descriptor or invocation internals.
Examples
Uses string.upper, Foo and Bar method calls, and inheritance diagrams to illustrate lookup across instances, classes, and parents.
What you can do after
Evaluate why an instance method call succeeds when the method is defined on its class or an inherited parent.

Read how Python Workout: 50 ten-minute exercises explains attribute lookup →

Python Workout, Second Edition

Attribute lookup is Python's process for resolving an attribute name through an object's instance, class, inheritance hierarchy, and ultimate base object.

How it is used
Applies attribute lookup to reason about instance attributes, class attributes, and inherited methods.
How deep it goes
Defines lookup across instances, classes, inheritance, and the ultimate base object, with examples of inherited methods.
Examples
Uses Foo and Bar inheritance, instance attribute x, inherited methods, and dataclass fields as concrete examples.
What you can do after
Evaluate how Python resolves an attribute on an instance and identify whether inheritance supplies the requested behavior.

Read how Python Workout, Second Edition explains attribute lookup →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.