I created this class to test some of the __getattr__
features:
class Trace:
def __init__(self, val):
self.val = val
def __setattr__(self, attr, value):
print('set ' + attr)
def __getattr__(self, attr):
print('get ' + attr)
I then created an instance
a = Trace(10)
print(a.val)
a.val = 5
print(a.val)
But, even if I fetched only existing attributes, this was the output:
set val
get val
None
set val
get val
None
I'm using Python 3.7.