How to override a magic method for the current script?
def __setattr__(name, value):
__dict__[name] = value
print("asd")
if name == 'b':
print(__dict__[name])
if __name__ == '__main__':
a = 3
b = 4
b = 5
In above, for example, I expect assignments to b
to call __setattr__
but they don't. What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…