Discuss / Python / 代码如下,为啥把其中的_width和_height前面的下划线去掉以后,就不行了呢(超过最大递归),难道不止是私有和公开的区别吗?求解

代码如下,为啥把其中的_width和_height前面的下划线去掉以后,就不行了呢(超过最大递归),难道不止是私有和公开的区别吗?求解

Topic source

class Screen(object): @property def width(self): return self._width @width.setter def width(self,value): self._width =value @property def height(self): return self._height @height.setter def height(self,value): self._height = value @property def resolution(self): return self._width * self._height


  • 1

Reply