[Tutor] This is the online help utility [tutorial].

bhaaluu bhaaluu at gmail.com
Wed Dec 5 14:11:33 CET 2007


Greetings,
Recently a thread about Python's online help utility was buried
within another thread with a different Subject. So I thought I'd
try to summarize that thread within a thread in a thread of its own.
It would be helpful for those running different versions of Python
on differnet systems to contribute their online help experiences
if they differ from what I'm posting. I'm running Python 2.4.3 in
bash, in a Konsole (KDE) running on the Linux 2.6.15 kernel.

1) Starting the Python Interactive Interpreter:

$ python
Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

It says to type "help", so that's what I type:

>>> "help"
'help'

Oops! That doesn't work very well now, does it?

>>> help
Type help() for interactive help, or help(object) for help about object.

Ahhhh! That's better. If I'm new to Python, I probably won't know what
'object' means
in help(object), so maybe 'help()' will be a good start?

 >>> help()

Welcome to Python 2.4!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://www.python.org/doc/tut/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help>

OK! The first thing I notice is that the interactive prompt has changed from
'>>>' to 'help>'.  There is some VERY USEFUL INFORMATION in the splash
text. For example, to get out of the help utility, and return to the
interpreter,
I need to type "quit" <-- it can be typed WITHOUT the quotes!

Three other words are suggested for use here: modules, keywords, and topics.
So now I have four words I can use at the 'help>' prompt to get help:
quit, topics, modules, and keywords.

help> keywords
Here is a list of the Python keywords.  Enter any keyword to get more help.

and                 else                import              raise
assert              except              in                  return
break               exec                is                  try
class               finally             lambda              while
continue            for                 not                 yield
def                 from                or
del                 global              pass
elif                if                  print

help> pass
------------------------------------------------------------------------

  6.4 The pass statement

        pass_stmt        ::=     "pass"

  Download entire grammar as text.[1]
[snip]

On my machine, when the help has ended, END is displayed, and I must
type a "q" to get back to the help prompt.

help> modules

Please wait a moment while I gather a list of all available modules...

ArgImagePlugin      UserList            fpectl              qtxml
ArrayPrinter        UserString          fpformat            quopri
BaseHTTPServer      WalImageFile        ftplib              random
[snip]
Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".

help> modules random

Here is a list of matching modules.  Enter any module name to get more help.

random - Random variable generators.
whrandom - Wichman-Hill random number generator.
_random
RNG (package) - x=CreateGenerator(seed) creates an random number
generator stream
RandomArray

Here again, when at the help> prompt, no quotes are necessary around
the words entered.

help> topics
 topics

Here is a list of available topics.  Enter any topic name to get more help.

ASSERTION           DELETION            LOOPING             SEQUENCES
ASSIGNMENT          DICTIONARIES        MAPPINGMETHODS      SHIFTING
ATTRIBUTEMETHODS    DICTIONARYLITERALS  MAPPINGS            SLICINGS
ATTRIBUTES          DYNAMICFEATURES     METHODS             SPECIALATTRIBUTES
[snip]

help> POWER
------------------------------------------------------------------------

  5.4 The power operator

  The power operator binds more tightly than unary operators on its left;
  it binds less tightly than unary operators on its right. The syntax is:

        power    ::=     primary[1] ["**" u_expr[2]]

  Download entire grammar as text.[3]
[snip]
:

The colon means I can type SPACE for another page, or ARROW key to move a line.
At the end, or at any time, I can type a "q" to return to the help> prompt.

help> quit

You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)".  Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.

>>>  Ctrl-D
$

When I quit help(), I'm returned to the Python interpreter's interactive prompt.
The ending message has some useful information in it! Read it!

Ctrl-D returns me to the bash prompt.

I think this summarizes what has been discussed so far?
Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m


More information about the Tutor mailing list