[Idle-dev] Weird error when pydoc.help is added to builtin from site.py
Patrick K. O'Brien
pobrien@orbtech.com
Mon, 11 Jun 2001 21:55:05 -0500
Here is a problem we discovered on the python-edu list. We are trying to add
pydoc help to the python environment by adding the following code to
site.py:
from pydoc import help
import __builtin__
__builtin__.help = help
del help
del __builtin__
For the most part this works. For example, in IDLE, you can do help(len) and
get the expected information. But try help with no value and you get the
following:
>>> help
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "c:\python21\lib\pydoc.py", line 1276, in __repr__
self()
File "c:\python21\lib\pydoc.py", line 1285, in __call__
self.interact()
File "c:\python21\lib\pydoc.py", line 1297, in interact
self.output.flush()
IOError: [Errno 9] Bad file descriptor
Any idea what the problem might be? And if we can get it to work, how do you
feel about introducing this as a PEP for Python? There is something of a
precedent in the existing code that defines "quit" and "exit". So it would
seem to make sense to define "help" as well.
--- snipped from site.py as support for PEP XXXXX ---
# Define new built-ins 'quit' and 'exit'.
# These are simply strings that display a hint on how to exit.
if os.sep == ':':
exit = 'Use Cmd-Q to quit.'
elif os.sep == '\\':
exit = 'Use Ctrl-Z plus Return to exit.'
else:
exit = 'Use Ctrl-D (i.e. EOF) to exit.'
import __builtin__
__builtin__.quit = __builtin__.exit = exit
del exit
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."