Other Attribute Management Tools
For future reference, also note that there are other ways to manage attribute access in Python:
- The __getattribute__ method intercepts all attribute fetches, not just those that are undefined, but when using it you must be more cautious than with __getattr__ to avoid loops.
- The property built-in function allows us to associate methods with fetch and set operations on a specific class attribute.
- Descriptors provide a protocol for associating __get__ and __set__ methods of a class with accesses to a specific class attribute.
Because these are somewhat advanced tools not of interest to every Python programmer, we’ll defer a look at properties until Chapter 31 and detailed coverage of all the attribute management techniques until Chapter 37.