[Tutor] concerning help() function

Dave Angel davea at ieee.org
Wed Jul 29 17:22:55 CEST 2009


David wrote:
> Dear Tutors,
>
> whenever I make use of the help() function, I have a good chance of
> getting an error. I have not yet understood this tool very well.
>
> Take the modules operator and random as examples. The former is
> built-in, the latter not.
> Do I wish to see the help files, I have to use a different syntax:
>
> help(random)
> help('operator')
>
> I figured this by trial and error, and I am keen to find out when the
> help() function is to be supplied with a string, and when no '' is
> required. It certainly does not seem intuitive to me!
>
> Many thanks,
>
> David
>
>
>   
As far as I know, the only difference between the two forms is that with 
the quotes, you can get help on a module that has *not* been imported, 
while if a module had been imported, you can leave off the quotes.

For those two modules, you need the quotes till you import them.  I 
don't see any difference between them, at least in :Python 2.6.2

For things that are really built-in, such as the function open(), you 
can get help without importing anything, since it's already visible.  So 
you can say help(open), or help(property).


DaveA


More information about the Tutor mailing list