The solution to this is to use the getter and setter methods - fortunately, Python has a built-in property()
to hide the ugliness of this.
class A: def __init__(): self.abc = 10 @property def aliased(self): return self.abc @aliased.setter def aliased(self, value): self.abc = value def anotherMethod(): self.aliased *= 10
As others have noted, this is usually a sign of poor design - you usually don’t want classes to know about objects that have three relationships - this means that changes to a given element can cause problems in the entire code base. It is a better idea to try to get each class to deal with the classes around it, and not further.
source share