Python provides a built-in help system in order to provide help and information about different modules, methods, classes, etc. This help system also provided with the help() method which will provide usage about the provided topic, module, class, keyword, etc.
The help() Method Syntax
The help() method has the following syntax where the single parameter is optional.
- OBJECT is optional which is generally a string that describes the method, function, variable, class, etc.
Help Interactive Shell
The help() method can be used to from the Python interactive shell. By running the help() method like below will start help interactive shell.
In this interactive help shell, we can type some text related to the help topic. In the following case, we will type "string" and press enter which will provide Name, Module Reference, Description, Classes, Functions, Data, File information about the string.
Access Help Information
The help() method can be used inside the Python script but the easiest and popular way to use it from the Python Interactive Shell. The help() method returns the help information as a Linux man page which contains Name, Module Reference, Description, Classes, Functions, Data, File. Below we can directly pass the "string" term to the help method which will show "string" help information.
Exit From Interactive Help Shell
We can exit from the interactive help shell by by pressing enter in the empty line. Just press enter two time in a row. Alternatively the CTRL+D can be used to exit from interactive help shell and return to the Python interactive shell.
Popular Help Topics
The help() method is an advanced search engine where it tries to find and match a given terms. Below we will list some popular help topics.
>>> help(True) >>> help("collections") >>> help("builtins") >>> help("modules") >>> help("keywords") >>> help("symbols") >>> help("topics") >>> help(math) >>> help(os) >>> help("def") >>> help(False)