Python: help() function

help() overview

The help() function in Python, calls the built-in help system. It can be called with or without an argument. If it is called without argument the general help system is opened. If it is called with an object as an argument it opens the help for a specific object.

help() syntax

The syntax of the help() function is: help([object])

Basic use of the help() function

If the help() function is called without any argument the interactive help utility is started. Use it to find more information about a specific topic. Welcome to Python 3.9's help utility! If this is your first time using Python, you should definitely check out the tutorial on the Internet at https://docs.python.org/3.9/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, symbols, or topics, type "modules", "keywords", "symbols", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose name or summary contain a given string such as "spam", type "modules spam". help> To use the help tool just type the topic you want to learn about. For example if we want to learn about strings we type string and receive the help object shown below. Help on module string: NAME string - A collection of string constants. DESCRIPTION Public module variables: whitespace -- a string containing all ASCII whitespace ascii_lowercase -- a string containing all ASCII lowercase letters ascii_uppercase -- a string containing all ASCII uppercase letters ascii_letters -- a string containing all ASCII letters digits -- a string containing all ASCII decimal digits hexdigits -- a string containing all ASCII hexadecimal digits octdigits -- a string containing all ASCII octal digits punctuation -- a string containing all ASCII punctuation characters printable -- a string containing all ASCII characters considered printable CLASSES builtins.object Formatter Template

find help about a specific topic

To find help about a specific topic, pass in the name of the topic as string to the help() function. # find help about the print function help('print') In this example, we want to open the help for the print() function and therefore pass the string 'print' to the help() function. The result is shown below. print(...) print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.

exit the interactive help

How to exit the interactive help? To leave the help utility just type quit and help is closed. It is also possible to use keyboard shortcuts, for example control + c on mac or control + z on windows.



Click to jump to section