[Python-Dev] onlinehelp.py

Paul Prescod paul@prescod.net
Sat, 22 Jul 2000 14:45:01 -0500


I've updated onlinehelp.py with some nice new features built on cool
code other people wrote. It's checked in.

1. Richard Chamberlain's wrote textdoc.py which builds on Ka-Ping Yee's
inspect.py. Together, they allow me to get a lot more introspective
information from modules and clsses even though they may not have
docstrings. It will even use comments as docstrings.

Thanks to Richard who wrote textdoc.py specifically for this purpose.

	>>> help( foo.__init__ )
	| __init__(self, qName, namespaceURI='', localName=None)
	|        no doc string


 2. If you ask for help on a string that it doesn't "know about", it
will attempt to import it. 

	>>> help( "profile" )
	| profile
	|       Class for profiling Python code.
	|
	| Modules:
	|
	| marshal, os, sys, time
	|
	| Classes:
	|
	| class HotProfile(Profile):
	|
	|       The fastest derived profile example.  It does not calculate
	|       caller-callee relationships, and does not calculate cumulative
	...

 3. It will also try to find the string as a sub-attr of a module. This
part is really cool:

	>>> help( "xml.dom.minidom.AttributeList.items" )

(note that xml.dom.minidom is a package, AttributeList is a class,
items, is a method)

All features are available from the Unix or Windows command line:

	python onlinehelp.py xml.dom.minidom.AttributeList.items

Have fun!

The rest of the message is an example transcript.

>>> help( "xml" )
<module 'xml' from 'c:\pysrc\python\dist\src\lib\xml\__init__.pyc'>
Topic: help( <module 'xml' from
'c:\pysrc\python\dist\src\lib\xml\__init__.pyc'>
 )
| xml
|       Core XML support for Python.
|
|       This package contains three sub-packages:
|
|       dom -- The W3C Document Object Model.  This supports DOM Level 1
+
|              Namespaces.
|
|       parser -- Python wrappers for XML parsers (currently only
supports Expat
).
|
|       sax -- The Simple API for XML, developed by XML-Dev, led by
David
|              Megginson and ported to Python by Lars Marius Garshol. 
This
|              supports the SAX 2 API.
|
| Modules:
|
| dom, sax
>>> help( "xml.dom" )
<module 'xml.dom' from
'c:\pysrc\python\dist\src\lib\xml\dom\__init__.pyc'>
Topic: help( <module 'xml.dom' from
'c:\pysrc\python\dist\src\lib\xml\dom\__init
__.pyc'> )
| xml.dom
|       W3C Document Object Model implementation for Python.
|
|       The Python mapping of the Document Object Model is documented in
<...>.
|
|       This package contains the following modules:
|
|       minidom -- A simple implementation of the Level 1 DOM with
namespace
|                  support added (based on the Level 2 specification).
|
| Modules:
|
| minidom, pulldom
>>> help( "xml.dom.minidom" )
<module 'xml.dom.minidom' from
'c:\pysrc\python\dist\src\lib\xml\dom\minidom.py'
>
| Topic: help( <module 'xml.dom.minidom' from
'c:\pysrc\python\dist\src\lib\xml\
dom\minidom.py'> )
| xml.dom.minidom
|       no doc string
|
| Modules:
|
| pulldom, string, types
|
| Classes:
|
| class Attr(Node):
|
|       no doc string
|
|       Methods:
|
|       __init__(self, qName, namespaceURI='', localName=None,
prefix=None)
|               no doc string
|
|       __setattr__(self, name, value)
|               no doc string
|
| class AttributeList:
|
|       the attribute list is a transient interface to the underlying
--more-- (enter for more, q to quit) q
0
>>> help( "xml.dom.minidom.AttributeList" )
| Topic: help( xml.dom.minidom.AttributeList )
| class AttributeList:
|
|       the attribute list is a transient interface to the underlying
|       dictionaries.  mutations here will change the underlying
element's
|       dictionary
|
|       Methods:
|
|       __cmp__(self, other)
|               no doc string
|
|       __delitem__(self, attname_or_tuple)
|               no doc string
|
|       __getitem__(self, attname_or_tuple)
|               #FIXME: is it appropriate to return .value?
|
|       __init__(self, attrs, attrsNS)
|               no doc string
|
|       __len__(self)
|               no doc string
|
|       __setitem__(self, attname, value)
--more-- (enter for more, q to quit) q
>>> help( "xml.dom.minidom.AttributeList.items" )
Topic: help( <unbound method AttributeList.items> )
| items(self)
|       no doc string
|
1
>>>
-- 
 Paul Prescod - Not encumbered by corporate consensus
New from Computer Associates: "Software that can 'think', sold by 
marketers who choose not to."