[Edu-sig] Re: [Idle-dev] Weird error when pydoc.help is added to builtin from site.py
Patrick K. O'Brien
pobrien@orbtech.com
Tue, 12 Jun 2001 11:55:14 -0500
Way cool. Thank you, Guido, for lending the help we needed. (No pun
intended, I swear.) I still remember the first time I ran python and typed
'help' at the prompt. Yikes! <grin> But not anymore. Now I'll get a friendly
response. I feel very good about this. Made it worth all the effort, and I
learned a thing or two. Time for a nap.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."
-----Original Message-----
From: guido@odiug.digicool.com [mailto:guido@odiug.digicool.com]On Behalf Of
Guido van Rossum
Sent: Tuesday, June 12, 2001 11:36 AM
To: Guido van Rossum
Cc: pobrien@orbtech.com; IDLE Developers List; ping@lfw.org; Python Edu SIG
Subject: Re: [Edu-sig] Re: [Idle-dev] Weird error when pydoc.help is added
to builtin from site.py
> 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/)