0 votes
1 view
in Data Science by (4.7k points)
I'd like to get help(obj) text in IPython or Jupyter notebook in a non-interactive manner, into some variable instead of it being displayed.

Note: help provides more information than obj.__doc__ provides, so that's not quite an alternative.

1 Answer

0 votes
by (9.8k points)

Short way:

import pydoc

help_result_string = pydoc.render_doc(obj)

Long way:

When you call help(obj), it is a wrapper to pydoc.help(obj) (see help.__doc__), which is the same as pydoc.Helper()(obj) (from pydoc source: help = Helper()), which usually leads to pydoc.doc(obj), which writes the resulting string from pydoc.render_doc(obj) to the standard output or a pager, depending on the system.

If you are a beginner and want to know more about Data Science the do check out the Data Science course

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...