__getattr__
Dunder MethodPython 2.0+Advanced
Called when the default attribute access fails
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
class Example: def __getattr__(self): return "Example __getattr__" obj = Example() print(obj)
__getattr__ called when the default attribute access fails. Implementing it lets you customize how Python interacts with your objects.
Try in PlaygroundTags
oopmagic-methodprotocolcore