[Tutor] Re: [Edu-sig] Python resources CD available [getting help() as a builtin]
Patrick K. O'Brien
pobrien@orbtech.com
Sat, 9 Jun 2001 11:16:21 -0500
I gave this a try (Adding Daniel's code to sitecustomize.py) and it didn't
quite work. Some stuff did and some didn't. As you can see from the sample
session below, help on a specific function works, but help with no
parameters does not. Weird. Daniel's code works when entered interactively
but not when loaded from sitecustomize.py. So then I tried the original
suggestion to add it to site.py and I get the same behavior. Can anyone else
confirm this? Daniel? I ran this on Win98SE with Python 2.1.
---
>>> 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
>>> help(len)
Help on built-in function len:
len(...)
len(object) -> integer
Return the number of items of a sequence or mapping.
>>>
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."
-----Original Message-----
From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Saturday, June 09, 2001 9:52 AM
To: Python-Edu SIG; tutor@python.org
Subject: RE: [Tutor] Re: [Edu-sig] Python resources CD available [getting
help() as a builtin]
Cool idea. Could I suggest a small change, though? The documentation for
site says this:
"After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations. If this import fails with an
ImportError exception, it is silently ignored."
So would it make more sense to create a sitecustomize.py file with your
code? I'm going to give it a try, as soon as I have another cup of coffee.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."
-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Daniel Yoo
Sent: Saturday, June 09, 2001 2:06 AM
To: Timothy Wilson
Cc: Python-Edu SIG; tutor@python.org
Subject: [Tutor] Re: [Edu-sig] Python resources CD available [getting help()
as a builtin]
>> Is it practical and possible to have pydoc's help() function
>> autoloaded by bundling a modified interpreter?
> Yes, I've followed that discussion on the tutor list too. I think some
> sort of interactive help would be great. I'm afraid modifying the
> interpreter is a bit beyond me at this point, however. Making the CD
> more interactive would be very cool, no doubt.
Yahoo! We don't need to recompile at all: we just need to append the
following to site.py within the library :
###
## (within site.py)
## Added by dyoo
from pydoc import help
__builtin__.help = help
del help
###
That will do it! Afterwards, help() will appear to be a builtin. I'll
crosspost this to the tutor list; people were wondering about this one.
This should definitely make things nicer for people.
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig