A Byte of Python

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 the str 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.


Press q to exit the help.


In case you need to get help for operators like print, then you need to set the PYTHONDOCS 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
>>> 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.