Python Forum

Full Version: what if __getattr__() can't find an attribute, either?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
what if __getattr__() can't find an attribute, either? what should it do? return None?
https://docs.python.org/3/reference/data..._getattr__ Wrote:object.__getattr__(self, name)
Called when the default attribute access fails with an AttributeError (either __getattribute__() raises an AttributeError because name is not an instance attribute or an attribute in the class tree for self; or __get__() of a name property raises AttributeError). This method should either return the (computed) attribute value or raise an AttributeError exception.