Interpreter-like help in cmd.Cmd

Peter Hansen peter at
Thu Jun 9 23:19:54 CEST 2005

Sarir Khamsi wrote:
> Is there a way to get help the way you get it from the Python
> interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the
> module cmd.Cmd? I know how to add commands and help text to cmd.Cmd
> but I would also like to get the man-page-like help for classes and
> functions. Does anyone know how to do that? Thanks.

 >>> dir(help)
['__call__', '__class__', '__delattr__', '__dict__', ...

[Hmm... unexpected result... let's see what it is.]

 >>> help.__class__
<class 'site._Helper'>

[ah... loading and looking for "_Helper"...]

class _Helper(object):
     """Define the built-in 'help'.
     This is a wrapper around (with a twist).


     def __repr__(self):
         return "Type help() for interactive help, " \
                "or help(object) for help about object."
     def __call__(self, *args, **kwds):
         import pydoc
         return*args, **kwds)

HTH :-)


More information about the Python-list mailing list