I would like to know if there is a way to "link" two attributes of a class or to give 2 names to a same attribute?
For example, I'm actually working on a script which create triangle from data given by users. My triangle is ABC. Sides of this triangle are AB, BC and CA. So the triangle has got these 3 attributes (self.AB, self.BC, self.CA). But AB = BA so I would like to allow users to do print myInstance.BA
instead of print myInstance.AB
.
So I thought to create the attribute self.AB and the property BA (which return self.AB). That work fine when I try to do print myInstance.BA
instead of print myInstance.AB
but I'm greedy...
I also would like to allow users to do myInstance.BA = 5
instead of myInstance.AB = 5
and when doing this also edit the attribute AB.
Is there is a way to do this ?