class Square: def __init__(self, L): self._L = L # note the underscore A = self.area if A > 10.0: raise ValueError(f'Area {A} above limit 10.0') # getter, defines self.L @property def L(self): return self._L @property def area(self): return self.L**2 if __name__=='__main__': small_sq = Square(0.5) print(f'small square: L = { small_sq.L} area = {small_sq.area}') # you are not allowed to change L after init small_sq.L = 10.0 # raises AttributeError # you are not allowed to define squares with area > 10.0 big_sq = Square(50.0) # raises ValueError print(f' big square: L = { big_sq.L} area = {big_sq.area}')