我正在阅读"绝对初学者的Python编程",并且在那里有这段代码:
@property def mood(self): unhappiness = self.hunger + self.boredom if unhappiness < 5: m = "happy" elif 5 <= unhappiness <= 10: m = "okay" elif 11 <= unhappiness <= 15: m = "frustrated" else: m = "mad" return m
它只是在运行中计算并返回计算.它不提供对私有属性或类的任何属性的访问.这是财产而不是方法更好吗?