As it is in the comments - the text that is displayed when asking for help
in Python is what is defined in the modules, classes or functions as "docstring" - it is available as the __doc__
attribute of the object in question, and is automatically created if the first expression inside 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. The Python help for classes, for example, joins all method declarations, and the docstrings of each other, in addition to the docstring of the class.
Internally, help uses the pydoc
module, and inside it, the function that retrieves 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 the 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 get an output like the one you ask for.