Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python get __doc__ documentation for instance variable

In python, I know I'm supposed to document instance variables like this:

self.x = 22
"""docstring for x"""

#: docstring for x
self.x = 22
self.x = 22 #: docstring for x

But I can't seem to find a way to get hold of that documentation in code. MyClass.x.__doc__ gives me the doc of the actual type that is in x

So the question is: How do I get "docstring for x" from self.x?

like image 779
Waldo Bronchart Avatar asked Apr 06 '26 17:04

Waldo Bronchart


1 Answers

This is a feature of documentation utilities such as Sphinx and Epydoc, not a standard feature of Python. I don't believe that there is any direct way of getting variable docstrings.

See http://epydoc.sourceforge.net/manual-docstring.html#variable-docstrings

like image 95
photoionized Avatar answered Apr 09 '26 05:04

photoionized