9,204 questions

12,662 answers

573 users

class Test: def __init__(self, n): self.n = n @property def n(self): return self.__n @n.setter def n(self, n): if n < 0: self.__n = 0 else: self.__n = 4 o = Test(3) print(o.n) o.n = -7 print(o.n) ''' run: 4 0 '''