Python help() Method Tutorial

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

help(OBJECT)
  • 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 from the Python interactive shell. Running the help() method like below will start the help interactive shell.

help()
Python Interactive Help 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, and File information about the string.

help> string
String Help

Access Help Information

The help() method can be used inside the Python script but the easiest and most popular way to use it is 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, and File. Below we can directly pass the “string” term to the help method which will show “string” help information.

>>> help("True")
Access Help Information

Exit From Interactive Help Shell

We can exit from the interactive help shell by pressing enter in the empty line. Just press enter two times in a row. Alternatively, the CTRL+D can be used to exit from the interactive help shell and return to the Python interactive shell.

Exit From Interactive Help Shell

Popular Help Topics

The help() method is an advanced search engine where it tries to find and match given terms. Below we will list some popular help topics. In the following example we list help information about Boolean, Collections, Builtins, Modules, Keywords,Symbols,Topics,math,os,def etc.

>>> help(True)
>>> help("collections")
>>> help("builtins")
>>> help("modules")
>>> help("keywords")
>>> help("symbols")
>>> help("topics")
>>> help(math)
>>> help(os)
>>> help("def")
>>> help(False)

Leave a Comment