Detect if a __getattribute__ call was due to hasattr
问题 I'm re-implementing __getattribute__ for a class. I want to notice any incorrect (meaning failures are expected, of course) failures of providing attributes (because the __getattribute__ implementation turned out quite complex). For that I log a warning if my code was unable to find/provide the attribute just before raising an AttributeError . I'm aware: __getattribute__ implementations are encouraged to be as small as simple as possible. It is considered wrong for a __getattribute__