'ipython: get the result of `??` (double question mark) magic command as string

The IPython builtin help system says:

Within IPython you have various way to access help:

  ?         -> Introduction and overview of IPython's features (this screen).
  object?   -> Details about 'object'.
  object??  -> More detailed, verbose information about 'object'.

The double question mark magic command (??) thereby prints the type, the docstring and – if available – also the source code of the respective object. I find this information really useful and I want it inside a str-variable (instead of printed directly).

I know thath obj.__doc__ gives the docstring but I guess there is a convenient way to get all the information that ?? produces at once. I look for something like:

# pseudo code
from IPython import magic
report = magic.double_question_mark(obj)

Is this possible? If so, how?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source