Python Help Mode: Using the Interactive Help Utility
Learn how to use Python's help() utility to explore modules, keywords, topics, objects, attributes, and built-in documentation.
Python includes an interactive documentation utility that helps you investigate unfamiliar code without leaving the interpreter. You can use it to look up language features, standard-library modules, built-in types and functions, object attributes, and conceptual syntax topics.
This utility is opened by help(). It is different from an ordinary Python expression: an expression evaluates code, while help mode searches and displays documentation.
Help mode is useful when you need to:
- Investigate an unfamiliar name in existing code.
- Check which methods a type provides.
- Learn about a Python syntax topic or keyword.
- Explore the standard library and importable modules.
The documentation is generated primarily by pydoc, Python's documentation system. The exact wording and entries can vary between Python versions and installed environments.
Start Python and enter help mode
Open a terminal or command prompt and start the interactive interpreter. Depending on your operating system and installation, use either command:
python
python3
The normal interactive interpreter is a read-evaluate-print loop (REPL). It commonly displays the >>> prompt:
>>> 2 + 3
5
Call help() without an argument to enter the persistent documentation utility:
>>> help()
Welcome to Python's help utility!
help>
The prompt changes from >>> to help>. Commands entered at help> are requests for documentation rather than ordinary Python expressions.
Look up documentation in help mode
Modules
At the help> prompt, enter a module name to read its documentation. For example:
help> math
If Python can resolve the name in the active environment, it displays information about the module. You can also use the string form:
help> 'math'
A module is a Python file or importable package component containing code, definitions, and documentation. The result depends on what is installed and importable in the current environment.
Keywords and named topics
A keyword is a reserved Python word with syntactic meaning, such as for, class, or import. Enter a keyword or a named documentation topic directly:
help> for
help> import
A topic is a conceptual documentation page for a language feature or category. For example:
help> NUMBERS
Some topic names are conventionally shown in uppercase. Enter them as displayed by the discovery commands.
Built-in types, functions, classes, and objects
You can request documentation for a built-in type or function:
help> str
help> len
You can also request help for an object name that Python can resolve in the current session. For example, after importing sys:
help> import sys
help> sys
In help mode, the import line is interpreted as a lookup request, not as an ordinary statement. To import a module normally, leave help mode and use import sys at the >>> prompt.
Discover available help categories
Help mode provides discovery commands for finding documentation when you do not know the exact name.
For example, search for modules related to JSON:
help> modules json
Module discovery can inspect importable packages, including third-party packages. It may take time or display import-related messages if packages have side effects or unavailable optional dependencies. When you already know the module name, a targeted request such as help('math') is usually preferable.
Read a topic: the NUMBERS example
Start by listing the available topics:
help> topics
Then select the numeric topic:
help> NUMBERS
Numeric literals are numbers written directly in Python source code. The topic discusses forms such as:
- Integers, for example
42. - Floating-point values, for example
3.14. - Imaginary-number notation, for example
2j.
At the end of topic output, Python may show related topics. These references are useful navigation links within the documentation system. Return to help> and enter a related topic name to continue exploring.
Inspect modules, attributes, and dotted names
A dotted name contains periods and refers to a member of a module or object. For example, sys.platform is an attribute of the sys module.
An attribute is a named value associated with a module, class, or object. Import a module at the normal interpreter prompt before inspecting names that are not already available:
>>> import sys
>>> sys.platform
'linux'
Then request documentation for the dotted attribute:
>>> help(sys.platform)
Because sys.platform is a string value, the output may primarily describe the str type rather than provide a long, dedicated explanation of the attribute's meaning. These are three different documentation targets:
- The value: the current object stored in
sys.platform. - The type: the behavior and methods of that value, such as
str. - The containing module: module-level documentation and descriptions of names in
sys.
Compare the attribute request with the module request:
>>> help(sys)
>>> help(sys.platform)
Use sys.platform as an expression when you need its current value, and use help(sys) for module-level context.
Use help() outside persistent help mode
You do not have to enter a persistent help> session. At the ordinary >>> prompt, call help() with an object:
>>> help(str)
>>> help(len)
>>> import sys
>>> help(sys)
>>> help(sys.platform)
Passing an object is generally more reliable than passing a text name because Python has already resolved the object explicitly. String-based lookup is useful for keywords, topics, and module names:
>>> help('for')
>>> help('math')
A direct call displays documentation and then returns to the normal >>> prompt. Persistent help mode changes the prompt and lets you issue multiple documentation requests without repeatedly calling help().
Understand common help output sections
Documentation output can be long. Common sections include:
- Description: what the object, module, or type represents.
- Call signature: how to call a function or construct an object, including parameter names and default values.
- Class hierarchy: parent classes and inheritance relationships.
- Methods: operations provided by a class or object.
- Data attributes: named values associated with a class or object.
- Module variables: names exposed by a module.
- Related topics: other help entries that may explain connected concepts.
When reading an unfamiliar entry, focus first on the object description, call signature, parameter names, return behavior, and examples if examples are present. Then inspect methods or related topics for details.
Output wording, signatures, available built-ins, and installed-module entries differ among Python releases and environments. The documentation produced by the interpreter you are using is the authoritative description for that environment.
Leave help mode
At the help> prompt, enter quit:
help> quit
>>>
This returns you to the normal interactive interpreter. Do not rely on pressing a blank Enter key as a universal exit method: behavior can vary. quit is the clear, supported command.
Troubleshooting
Python cannot be found
If the shell reports that python is not recognized or cannot be found, Python may not be installed or its executable directory may not be on the system PATH. Install a supported Python version and use the platform-appropriate launcher, or add Python to PATH according to your installation method. See installing Python on Windows, installing Python on Linux, or adding Python to the Windows PATH.
A help name cannot be found
Check spelling and capitalization. The name may not be installed, importable, or recognized as a documentation topic. Use topics or keywords for discovery, search with modules <term>, or import the relevant module and call help() on its object.
help(sys.platform) mainly describes str
sys.platform is a string value, so pydoc may expose documentation for its type. Use help(sys) for module context and evaluate sys.platform to see the current value.
modules is slow or displays warnings
Module enumeration may inspect many packages. Third-party imports can have side effects or depend on optional components. Use a targeted command such as modules json or request a known module with help('module_name').
You cannot leave the help prompt
Enter quit at help>. This is more dependable than a blank line or an unsupported exit method.
Quick reference
# Start Python
python
python3
# Enter persistent help mode
>>> help()
help> topics
help> keywords
help> symbols
help> modules
help> modules json
help> NUMBERS
help> quit
# Request help at the normal prompt
>>> help(str)
>>> help(len)
>>> help('for')
>>> help('math')
>>> import sys
>>> help(sys)
>>> help(sys.platform)
For more practice with the normal interpreter, see Python's interactive prompt. To investigate module contents further, see importing modules and displaying module content. Help mode is also a useful companion to learning Python data types.