O'Reilly logo
  • Chris Kang thinks this is interesting:

When these lookup steps do not find an attribute, Python raises an AttributeError exception. However, for lookups of x.name, when C defines or inherits the special method __getattr__, Python calls C.__getattr__(x,'name') rather than raising the exception. It’s then up to __getattr__ to either return a suitable value or raise the appropriate exception, normally AttributeError.


Cover of Python in a Nutshell, 3rd Edition


getattr is the last thing Python will check.