What does `__getattr__` do in Python?

Python Professional Hard

Python Professional — Hard

What does `__getattr__` do in Python?

Key points

  • `__getattr__` is a fallback mechanism for attribute access
  • It is not called for every attribute access
  • It is a powerful tool for dynamic attribute handling

Ready to go further?

Related questions