10. Dunder getattr Method
__getattr__ is called when an attribute lookup fails.
Example
class Dynamic:
def __getattr__(self, name):
return f"{name} not found"
d = Dynamic()
print(d.missing)
Use Cases
- Delegating attribute access
- Creating proxies or fallback values
Wrap-Up
__getattr__ gives control over missing attributes, enabling dynamic behaviors.