The special function property links an attribute to such a getter, setter, and deleter method. It might also be used to assign a documentation string to an attribute:
attribute = property(fget = get_attr, fset = set_attr, fdel = del_attr, doc = string)
We continue with the previous example with a setter method and consider the class Triangle again. If the following statement is included in the definition of this class, the command tr.B = <something> invokes the setter method set_B:
B = property(fget = get_B, fset = set_B, fdel = del_B,
doc = ’The point B of a triangle’)
Let's modify the Triangle class accordingly:
class Triangle: def __init__(self, A, B, C): self._A = array(A) self._B = array(B) self._C = array(C) self._a = self._C - self._B self._b = self._C - self._A self._c = self._B - self._A def area(self): return abs(cross(self._c...