Python help() Function Explained

Python’s help() function shows built-in documentation inside Python.

It is useful when you want to quickly inspect a function, class, method, or module without leaving the Python shell. For beginners, it is a simple way to check what something does, what arguments it accepts, and how it is meant to be used.

Quick example

help(len)
help(str)
help('modules')

Use help() to view built-in documentation in the Python shell. Pass an object like len or str, or use a string such as 'modules' for special interactive help topics.

What help() does

help() displays Python’s built-in documentation.

You can use it to inspect:

  • Functions
  • Classes
  • Methods
  • Modules
  • Some Python keywords and help topics

It is most useful in the Python shell, IDLE, or another interactive environment.

For example, if you forget how len() works, you can ask Python directly:

help(len)

This is helpful when you are learning because you can explore Python while you code.

Basic syntax

The main form is:

help(object)

You pass in the thing you want to learn about.

Common examples include:

  • len
  • list.append
  • str
  • open

You can also call help() with no argument:

help()

This opens interactive help mode, where you can type help topics and search for information from inside Python.

Common things you can inspect

Built-in functions

You can inspect built-in functions such as len, print, input, and type().

help(print)
help(input)
help(type)

Data types

You can inspect types such as str, list, dict, and set.

help(str)
help(list)
help(dict)

This is useful when you want to see available methods and basic behavior for a type.

Methods

You can inspect methods such as str.split and list.append.

help(str.split)
help(list.append)

If you are not sure what methods a type has, compare help() with dir(). dir() shows available names, while help() explains one of them.

Modules

You can inspect modules such as math, json, and os.

import math
help(math)

If you are still learning imports, see how import works in Python. For a beginner-friendly module example, see the Python math module overview.

How to read the output

help() output can look long at first. Do not try to read everything.

Focus on these parts first:

  • The function signature
  • The short description
  • Parameter names
  • Return value details, when shown

For example:

help(str.split)

When you read the output, look for:

  • What object this is
  • What arguments it accepts
  • What it returns
  • Short notes about how it behaves

A good beginner habit is to read the first few useful lines, then test the function yourself with a small example.

When help() is useful

help() is useful when:

  • You forget how a built-in function works
  • You want to check method names on a type
  • You are exploring a new module
  • You want quick documentation while coding

For example, if you remember that strings have a method for splitting text but forget the exact details, you can run:

help(str.split)

If you want to inspect file handling, you can also check:

help(open)

Limits of help()

help() is useful, but it has limits.

  • The output can feel dense for beginners
  • Some third-party libraries may have unclear or incomplete help text
  • It does not replace simple examples
  • It works best when combined with small practice programs

So, help() is great for quick checking, but you will usually learn faster if you also test what you read in short code examples.

For example:

text = "a,b,c"
parts = text.split(",")

print(parts)

Expected output:

['a', 'b', 'c']

A good workflow is:

  1. Use help() to inspect something
  2. Write a tiny example
  3. Check the result
  4. Repeat

Difference between help() and dir()

help() and dir() are often used together, but they do different jobs.

help()

Use help() when you want an explanation.

It tells you:

  • What something is
  • How to use it
  • What parameters it accepts

dir()

Use dir() when you want a list of available names or attributes.

dir(str)

This shows many string methods, such as split, strip, and lower.

Then you can inspect one of them with help():

help(str.lower)

A simple way to remember the difference:

  • Use dir() to discover options
  • Use help() to understand one option

Common mistakes

Beginners often run into these small problems when using help().

Using help('len') when you meant help(len)

These are not always the same.

help(len)
help('len')

help(len) asks for help on the actual function object.

help('len') treats 'len' as a help topic string. That can work differently, so when you want to inspect a real function, use the function name without quotes.

Expecting short, example-based output

help() is documentation, not a tutorial.

The text may be longer and more technical than you expect. Start with the first lines, then test the function yourself.

Running help() in a script and not noticing where output goes

If you call help() in a normal Python script, the documentation text is printed to the terminal or console.

Example:

help(len)
print("Done")

You may not see a neat interactive display like you do in the Python shell.

Confusing help() with dir()

If you want a list of methods, use dir().

If you want an explanation of one method, use help().

Useful commands to try

Open Python:

python

Then test these commands:

help(len)
help(str.split)
help(list.append)
help(open)
help('keywords')
dir(str)

These are good starting points because they show different kinds of objects:

  • A built-in function
  • A string method
  • A list method
  • A built-in file function
  • A special help topic
  • A dir() example for comparison

FAQ

What does help() return in Python?

It mainly prints documentation text to the screen. It is used for inspection, not for producing a useful return value in normal beginner code.

Can I use help() on my own functions?

Yes. You can pass your own function to help() to see its name, parameters, and docstring if it has one.

def greet(name):
    """Return a friendly greeting."""
    return f"Hello, {name}!"

help(greet)

What is the difference between help(len) and help('len')?

help(len) asks for documentation for the actual function object. help('len') treats the value as a help topic string, which is a different lookup style.

Why is help() useful for beginners?

It gives quick built-in documentation inside Python, so you can check how something works without searching elsewhere first.

See also

Try help() on three built-in functions you already know, such as len, print, and input. Then compare what you learn with dir(str) or dir(list) to build confidence exploring Python on your own.