[Python-Dev] The decorator(s) module (original) (raw)
Alex Martelli aleaxit at gmail.com
Sat Feb 18 01:02:05 CET 2006
- Previous message: [Python-Dev] The decorator(s) module
- Next message: [Python-Dev] The decorator(s) module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] The decorator(s) module
- Next message: [Python-Dev] The decorator(s) module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]