"help( pi )"

Python python at bladeshadow.org
Fri Nov 17 18:34:23 EST 2017


On Sat, Nov 18, 2017 at 09:50:29AM +1100, Chris Angelico wrote:
> Perhaps what we want is not so much "attach docstrings to floats" but
> "get documentation for a module attribute, not for the object referred
> to".

The reason this can't really work is that members are just variables
with arbitrary values.  It does not make sense for them to have doc
strings.

You *can* (and probably should!) document the members in the class'
(or module's) doc string.  That's really the only sensible place to do
it.  But remember that Python's idea of objects is more fluid than in
other languages...  You don't have constants, so you can arbitrarily
change any object's member values to anything, even to the point of
adding new ones at your whim.

This probably would make more sense for constants, if Python had them.
But you don't really need them, and there's no reason documenting 
the purpose of the members of a class or module in the parent object's
doc string shouldn't be sufficient.





More information about the Python-list mailing list