help()

A REPL tool, not a library function. It prints and returns None, which is exactly why it disappoints inside a script.

Built-in functionPython 2.2+
Common call
help(str.split)
Returns
None — the text goes to stdout, not to you
Replaces
switching to a browser to read the docs
Watch out
help(f()) documents the RESULT; you almost always meant help(f)
help([object])
None

Parameters

NameTypeRequiredDescription
objectAnynoAnything — a module, class, function, method, or a string naming one. Omitted starts the interactive help session.

Return value

NoneReturns None. The documentation is PRINTED, often through a pager — it is not a value you can capture.

Examples

1. A method
help(str.split)
Returns
prints the signature and docstring
2. A whole module
import json help(json)
Returns
prints the module overview
3. By name
help('modules')
Returns
lists every importable module
4. Interactive
help()
Returns
starts the help> prompt
5. Returns nothing
x = help(len) x
Returns
None
6. Get the raw text
str.split.__doc__
Returns
the docstring as a string

Pitfalls

1. It returns None, it does not give you text
help prints as a side effect. Assigning the call gets you None, and the documentation has already gone to stdout where your code cannot reach it.
Nothing captured
text = help(len)
print(text)
None
Read the docstring
text = len.__doc__
the actual text
2. Calling the function instead of naming it
help(f()) evaluates f first and documents whatever came back — often an int or a string, giving you the docs for that type instead. The mistake looks harmless because it still prints something.
Documents the result
help(len("abc"))
documents int, not len
Pass the object
help(len)
documents len
3. It blocks in a pager
On most systems long output goes through a pager and waits for a keypress. In a script, a CI job or a notebook cell that means a hang rather than an error.
Hangs the run
help(os)   # inside a script
waits for input at the pager
Use pydoc offline
python -m pydoc os
prints and exits
4. Only as good as the docstrings
help reads __doc__ at runtime, so undocumented code shows almost nothing — and a C extension without docstrings may show only a bare signature.
Empty output
def f(x):
    return x
help(f)
f(x) and no description
Write a docstring
def f(x):
    """Return x unchanged."""
    return x
the description appears

When to use

Use it
  • Exploring an unfamiliar API from the REPL
  • Checking a signature without leaving the interpreter
  • Listing available modules with help("modules")
Reach for something else
  • Inside scripts or libraries — it prints and can block
  • You want the text as a value → __doc__ or inspect.getdoc
  • You want the signature programmatically → inspect.signature

Notes

Complexity
Not meaningful — introspects the object and formats text
Return
Always None; the output goes to stdout
CPython impl
Lib/_sitebuiltins.py :: _Helper, delegating to Lib/pydoc.py
Memory
Builds the documentation text transiently
Thread-safe
Writes to stdout — interleaves badly with other threads printing

FAQ

help is built to print. Use inspect.getdoc for cleaned-up docstring text, or pydoc.render_doc for something closer to what help displays.

import inspect
text = inspect.getdoc(str.split)

History

2.2
help added as a site builtin, wrapping the pydoc module.
3.4
Output improved for signatures via the inspect.signature machinery.