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