Actually I can not figure out the setter. Those. With this code, if I initialize an instance of the wall_e class with a value of -100, then it should have a value of 0. For books, in practice, it doesn’t happen anywhere. Can anyone come across
class Robot: def __init__(self, power): self._power = power power = property() @power.setter def power(self, value): if value < 0: self._power = 0 else: self._power = value @power.getter def power(self): return self._power wall_e = Robot(-100) #wall_e.power = 20 print(wall_e.power)
self._power
around it - andreymal pm