I'm struggling with __getattr__
. I have a complex recursive codebase, where it is important to let exceptions propagate.
class A(object):
@property
def a(self):
raise AttributeError('lala')
def __getattr__(self, name):
print('attr: ', name)
return 1
print(A().a)
Results in:
('attr: ', 'a')
1
Why this behaviour? Why is no exception thrown? This behaviour is not documented (__getattr__
documentation). getattr()
could just use A.__dict__
. Any thoughts?