Is there a more pythonic way of 'linking' attributes such that when one attribute in a class is changed, another can be automatically changed according to some relation that I define?
Currently, I'm doing something like:
class myClass(object):
def __init__(self):
self.x = 1
self.y = 2 * self.x
pass
def set_x(self, x):
self.x = x
self.y = 2 * self.x
return
A = myClass()
print A.x #prints 1
print A.y #prints 2
A.set_x(5)
print A.x #prints 5
print A.y #automatically changes to 10