class Exam(object): def __init__(self,score): self._score=score @property def score(self): return self._score @score.setter def score(self,value): self._score=value
In [16]: v=Exam(67) In [17]: v.score Out[17]: 67 In [18]: v.score=40 In [19]: v.score Out[19]: 40