As it is in the comments - the text that is displayed when the help
Python is what is defined in modules, classes or functions as "docstring" - it becomes available as the attribute __doc__
of the object in question, and is created automatically if the first expression within the body of a module, class or function (including method) is a string:
In [6]: import math
In [7]: math.sin.__doc__
Out[7]: 'sin(x)\n\nReturn the sine of x (measured in radians).'
However, objects do not always include a meaningful docstring - and it is not always enough. Python’s help for classes, for example, joins all the method statements, and the docstrings of each, in addition to the class docstring.
Internally, help uses the module pydoc
, and, inside, the function that recovers the full text of the help is called render_doc
.
Therefore:
>>> import gtk
>>> import pydoc
>>> text = pydoc.render_doc(gtk.Box)
>>> print (text)
...
However - even enderdoc does not retrieve the signature of the functions that are written in C, or if they use the *args, **kwargs feature. This is the case for most Pygtk functions - so it is not possible to have an output like the one you ask for.
is not answer to what questions but, for example after
import math
,help(math.sin)
or on the command linepydoc math.sin
can help...– JJoao
All right, I can do that. You wouldn’t happen to know how to get help to pass the text to a string variable, instead of imprinting it? So you could easily locate the part that matters with String.find(text_de_interest).
– David Jesse
I’m not sure :( -- usually what you want is in
math.f.__doc__
for all relevant symbolsf
indir(math)
– JJoao