At 06:23 PM 9/28/2005 -0400, Barry Warsaw wrote: >I /must/ be missing something. Why not just use property as a >decorator? > >class C: > @property > def eggs(self): > print 'in eggs' > self.eggs = 7 > return self.eggs > > >>> c = C() > >>> c.eggs >in eggs >7 > >>> c.eggs >7 Because it only works in classic classes due to a bug in descriptor handling: >>> class C(object): @property def eggs(self): print 'in eggs' self.eggs = 7 return self.eggs >>> c=C() >>> c.eggs in eggs Traceback (most recent call last): File "<pyshell#12>", line 1, in -toplevel- c.eggs File "<pyshell#10>", line 4, in eggs self.eggs = 7 AttributeError: can't set attribute
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4