0 votes
1 view
in Python by (47.8k points)

I am trying to understand when to use __getattr__ or __getattribute__. The documentation mentions __getattribute__ applies to new-style classes. What are new-style classes?

1 Answer

0 votes
by (107k points)

The main difference between __getattr__ and __getattribute__ is that if the attribute was not found by the usual way then __getattr__ is used.

Whereas the __getattribute__ is used before looking at the actual attributes on the object. You will have to use it more consciously otherwise very easily you can end up in infinite recursions.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...