0

I understand how Python docstrings work and I regularly use pydoc.render_doc to access function docstrings. However, I don't know how to use render_doc to access the help topics, e.g. help("UNARY"). I don't even know where such a docstring would exist. Is there a way to either a) access help topics with pydoc or b) an alternative way to capture the help text in a variable?

help("UNARY")                         # prints help to console
import pydoc
pydoc.help("UNARY")                   # prints help to console
test = pydoc.render_doc("str")        # writes help to variable

test = pydoc.render_doc("UNARY")      # ERROR
pydoc.help("UNARY")                   # prints help to console
test = pydoc.help("UNARY")            # prints help to console, 'test' is empty

1 Answer 1

1

pydoc will work in commandline. Use the below command to generate the html documentation for the python modules in the current location.

C:>python -m pydoc -w sys wrote sys.html

But pydoc command cannot be used for Keywords and topics

Refer https://svn.python.org/projects/sandbox/trunk/setuptools/pydoc.py to know the list of topicss and keywords.

Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't answer my question. I'm looking for a way to capture the help text in a variable. I don't need a way to get the list of topics and I don't see how running pydoc in the command line helps, especially since you say it can't be used with keywords and topics.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.