[Tutor] Random Number Generator

bhaaluu bhaaluu at gmail.com
Tue Dec 4 23:41:57 CET 2007


On Dec 4, 2007 2:29 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "bhaaluu" <bhaaluu at gmail.com> wrote
>
> > You can use Python itself for getting help:
> >
> >>>> help('random')
>
> Well, well. I've been busily importing everything I wanted help on,
> not realising I could just quote it!
>
> Now that little insight has probably saved me an hour a year or more!
>
> Thanks for that ;-)
>
> Alan g.
>

For purposes of pedagogy, perhaps this requires more explanation?

I'm running the Python 2.4.3 interactive interpreter
in a Konsole at a bash prompt:

$ python

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

>>>  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>   <--Note: the prompt has changed! I'm in help() now.
help> 'random'
Help on module random:

NAME
    random - Random variable generators.
[snip]
:     <--Note: Press space bar for next page, or Arrow keys for lines

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.

>>>    <-- Note: I'm back in the Python interactive interpreter.

>>> [Ctrl-D]  <-- Press 'Ctrl' + 'd' to exit the interactive interpreter.
$  <-- back at the bash prompt

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