On 2/17/06, Georg Brandl <[EMAIL PROTECTED]> 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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to