What is the output of the following code ?
class A: X = 10 def __setattr__(self, key, value): print("__setattr__ is called") a = A() a.Y = 10 A.k = 90 print(a.X, a.k)
AttributeError : 'A' object has no attribute 'k'
10 90
__setattr__ is called __setattr__ is called 10 90
__setattr__ is called 10 90
Whenever we set a avalue to an attribute of an instance __setattr__ () is called .
But it will never be invoked when we set class attribute for A.k = 90
a.k can fetch class atrribute vale k and prints 90
Comment here: