Python by Swaroop C H - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Getting Help

If you need quick information about any function or statement in Python, then you can use the built-in help functionality. This is very useful especially when using the interpreter prompt. For example, run help(str) - this displays the help for thestr class which is used to store all text (strings) that you use in your program. Classes will be explained in detail in the chapter on object-oriented programming.

Note

Press q to exit the help.

 

Similarly, you can obtain information about almost anything in Python. Usehelp() to learn more about usinghelp itself!

 

In case you need to get help for operators likeprint, then you need to set thePYTHONDOCS environment variable appropriately. This can be done easily on Linux/Unix using the env command.

$ env PYTHONDOCS=/usr/share/doc/python-docs-2.3.4/html/ python Python 2.3.4 (#1, Oct 26 2004, 16:42:40)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> help('print')

You will notice that I have used quotes to specify'print' so that Python can understand that I want to fetch help about 'print' and I am not asking it to print something.

 

Note that the location I have used is the location in Fedora Core 3 Linux - it may be different for different distributions and versions.