python - Difference between __getattr__ vs __getattribute__ -


I am trying to understand when __getattr __ or __getattribute __ Use . Mention __getattribute __ is applicable for new-style classes What are the new style classes?

">

This is that if __getattr __ is applicable only when properties are not found in normal way. Good for implementing a fallback for missing properties, and possibly one of two.

__ getattribute __ is applied before viewing the actual attributes on the object, and therefore it is difficult to implement correctly you end up with infinite memories very easily You can.

New-style classes come from object , old-style ones are in Python 2.x, without any explicit base class. Distinguishing between old-style and new-style sections is not important when selecting between __getattr __ and __getattribute __ .

You almost certainly want __getrate____ .


Comments