[Edu-sig] Re: [Idle-dev] Weird error when pydoc.help is added to builtin from site.py

Guido van Rossum guido@digicool.com
Tue, 12 Jun 2001 12:35:41 -0400


> But a better solution (I think) is to add this to site.py:
> 
>   class _Helper:
>       def __repr__(self):
>           return "Please type help() for interactive help."
>       def __call__(self, *args, **kwds):
>           import pydoc
>           return pydoc.help(*args, **kwds)
> 
>   help = _helper()

Sorry, there are some typos in it, and the message could be
friendlier.  How about this (insert after the assignment to
__builtin__.license in site.py):


# Define new built-in 'help'.
# This is a wrapper around pydoc.help (with a twist).

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

__builtin__.help = _Helper()


--Guido van Rossum (home page: http://www.python.org/~guido/)