Docstrings and class Attributes

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Aug 9 02:51:10 CEST 2011


Ben Finney wrote:

> Ethan Furman <ethan at stoneleaf.us> writes:
> 
>> So if property docstrings are so hard to get to, what's the point in
>> having them?
> 
> Why would you expect there be a special point to them?
> 
> Men, like all primates of any sex, have nipples.
> 
> Properties, like any function in Python, have docstrings.
> 
> They're an accident of the history that led to their implementation, and
> of the pre-existing parts that they're built from. There doesn't need to
> be a point to them (though they might be useful for reasons incidental
> for the reasons they exist).

But properties *aren't* functions, they are objects which obey the
descriptor protocol. Perhaps you are thinking of the individual getter,
setter and deleter parameters to property(). If so, then your comment is
relevant as far as it goes to the docstrings on the individual
getter/setter/deleter functions. But property() itself explicitly takes a
docstring parameter. It is that docstring that seems of limited value,
except that Eric Snow has pointed out that help(instance) will display
property help strings.


-- 
Steven




More information about the Python-list mailing list