On 2/17/06, Georg Brandl <g.brandl at gmx.net> wrote: > Ian Bicking wrote: > > >> Unfortunately, a @property decorator is impossible... > > > > It already works! But only if you want a read-only property. Which is > > actually about 50%+ of the properties I create. So the status quo is > > not really that bad. > > I have abused it this way too and felt bad every time. > Kind of like keeping your hat on in the church. :) It's not ideal, because the resulting r-o property has no docstring: >>> class ex(object): ... @property ... def amp(self): ... ''' a nice docstring ''' ... return 23 ... >>> ex.amp.__doc__ >>> class xe(object): ... def amp(self): return 23 ... amp=property(amp, doc='whatever!') ... >>> xe.amp.__doc__ 'whatever!' >>> Maybe we could fix that by having property(getfunc) use getfunc.__doc__ as the __doc__ of the resulting property object (easily overridable in more normal property usage by the doc= argument, which, I feel, should almost invariably be there). Alex
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