Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (47.6k 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 (106k 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.

Related questions

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

28.4k questions

29.7k answers


94.2k users

Browse Categories