Pythonic object-oriented programming

We've seen a few important features of Python's approach to object-orientation. Perhaps the most important is that Python lacks a static binding between variable name and type; any type of object can be assigned to any variable. Names are not resolved statically by a compiler. Python's dynamic name resolution means that we can think of our programs as being entirely generic with respect to class.

When we evaluate obj.attribute or obj.method(), there are two steps. First the name, attribute or method, must be resolved. Second the referenced attribute or method is evaluated.

For the name resolution step, there are several namespaces that are searched to determine what the name means.

  • The local namespace of the ...

Get Python Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.