# How to override __setattr__ __getattr__ method
class Overrider(object):
def __init__(self, x):
self.x = x
#print(self.__dict__)
def __setattr__(self, key, value):
print("Changing:")
super(Overrider, self).__setattr__(key, value)
def __getattribute__(self, key):
#if key.startswith('_'):
# return super(Overrider, self).__getattribute__(key)
return super(Overrider, self).__getattribute__(key)*3
obj = Overrider(10)
obj.x = 5
obj.x
IyBIb3cgdG8gb3ZlcnJpZGUgX19zZXRhdHRyX18gX19nZXRhdHRyX18gbWV0aG9kCmNsYXNzIE92ZXJyaWRlcihvYmplY3QpOgogICAgZGVmIF9faW5pdF9fKHNlbGYsIHgpOgogICAgICAgIHNlbGYueCA9IHgKICAgICAgICAjcHJpbnQoc2VsZi5fX2RpY3RfXykKICAgIAogICAgZGVmIF9fc2V0YXR0cl9fKHNlbGYsIGtleSwgdmFsdWUpOgogICAgICAgIHByaW50KCJDaGFuZ2luZzoiKQogICAgICAgIHN1cGVyKE92ZXJyaWRlciwgc2VsZikuX19zZXRhdHRyX18oa2V5LCB2YWx1ZSkKCiAgICBkZWYgX19nZXRhdHRyaWJ1dGVfXyhzZWxmLCBrZXkpOgogICAgICAgICNpZiBrZXkuc3RhcnRzd2l0aCgnXycpOgogICAgICAgICMgICAgcmV0dXJuIHN1cGVyKE92ZXJyaWRlciwgc2VsZikuX19nZXRhdHRyaWJ1dGVfXyhrZXkpCiAgICAgICAgcmV0dXJuIHN1cGVyKE92ZXJyaWRlciwgc2VsZikuX19nZXRhdHRyaWJ1dGVfXyhrZXkpKjMKCm9iaiA9IE92ZXJyaWRlcigxMCkKb2JqLnggPSA1Cm9iai54