On 2 May 2017 at 13:47, Jason Maldonis <jjmaldo...@gmail.com> wrote: > Hi everyone, > > If this should be asked in learn python I apologize -- please just tell me > without answering. > > I'm working on a large class architecture and I find myself often > overloading __getattr__. I am continuously running into the issue where I > want __getattr__ to have access to the error that was raised in > __getattribute__, but it seems completely unavailable. Is that true?
__getattr__ can be called *from* __getattribute__, so when it runs, __getattribute__ hasn't necessarily failed yet - it may just be on its last resort strategy for attribute retrieval. If you're sure the base class __getattribute__ doesn't call __getattr__ directly, you can do: def __getattribute__(self, name): try: return super().__getattribute__(name) except AttributeError: return self.__getattr__(name) However, would you mind filing a documentation bug for this? I can't find anything in the language or library reference that explicitly states whether or not `object.__getattribute__` itself calls `__getattr__` directly, and that's a docs limitation which should be addressed. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com