Re: [問題] @property已刪文

看板Python作者 (阿寬)時間1年前 (2022/08/17 11:18), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
※ 引述《tsaiminghan (nahgnimiast)》之銘言: : class A(object): : @property : def x(self): : return self._x : @x.setter : def x(self, value): : self._x = value 如果有寫錯希望其他板上大大指正 property本身是class property(fget=None, fset=None, fdel=None, doc=None) # 當成decorator使用 @property def x(self): return self._x # 還原decorator def getx(self): return self._x x = property(fget = self.getx) 而property的getter與setter 也會回傳property 也可以當成decorator使用 # x setter當decorator使用 @x.setter def x(self, value): self._x = value # 還原decorator def setx(self, value): self._x = value x = x.setter(self.setx) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 133.51.216.27 (日本) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1660706335.A.F11.html
文章代碼(AID): #1Y_5uVyH (Python)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 4 篇):
1
16
文章代碼(AID): #1Y_5uVyH (Python)