Getting Started with the Python Interpreter
Python's built-in help() function provides immediate access to documentation about functions, statements, and objects without leaving the interpreter.
A Documentation Shortcut
When you are working in the Python interpreter, you may encounter a function, statement, or other object that you do not yet understand. Python provides a built-in help system so you can request documentation without leaving the interpreter. The help() function is especially useful for quick lookups while you are actively coding.
The central choice is whether you call help() with an argument for a focused lookup or without an argument to enter interactive help mode.
Focused Lookups at the Prompt
To request documentation about one particular function, call help() with an argument. The source material presents the common form help('function_name'), where the function name is supplied as a string. Python displays documentation about the requested function and then returns you to the normal interpreter prompt automatically. This mode is useful when you want a quick answer about what a function does or how to use it.
Looking Up One Function
You are at the Python prompt and need quick documentation about a function.
- 1Request
Call
help()with the function name as a string, using the formhelp('function_name'). - 2Read
Python displays documentation for the requested function.
- 3Continue
After the documentation is displayed, Python returns you to the normal prompt automatically.
A focused help request gives you documentation and returns control to the interpreter without requiring you to leave it.
Entering Interactive Help
Calling help() without an argument starts interactive help mode. In this mode, you can browse and search for topics instead of requesting only one known item. Unlike a focused lookup, interactive help does not return to the Python prompt automatically. You remain in the help interface until you exit it.
- 1At the normal Python prompt, enter
help()without an argument. - 2Use the interactive help interface to browse or search for a topic.
- 3Read the documentation that the help system displays.
- 4Press q when you want to leave interactive help.
- 5Continue working at the normal Python prompt.
Teaching the Help System About Itself
The help system is self-documenting. You can use help() to learn about help itself, including information about the help system and how to navigate it. This creates two related but different actions: calling help(help) requests focused documentation about help, while calling help() with no argument enters the interactive interface in which you can browse or search for topics.
Learning About help()
You know that Python has a built-in help system, but you want information about the help system itself.
- 1Focused route
Use
help(help)to request focused documentation about help. - 2Interactive route
Use
help()with no argument when you want to enter the interactive help interface and browse or search for information about the help system and its navigation. - 3Choose by goal
Use the focused route when you want documentation about help itself; use the interactive route when you want to explore topics.
Python's help functionality can explain both other Python objects and its own capabilities.
Mistakes Beginners Make
Common mistake Expecting help() without arguments to return immediately to the Python prompt
What it looks likeEntering help() and then trying to use the interpreter as though interactive help had already closed
Why it failsCalling
help()without arguments enters an interactive mode that remains active until you exit it.Do this insteadPress q to leave interactive help and return to the normal Python prompt.
Common mistake Confusing a focused lookup with interactive help
What it looks likeTreating help('function_name') and help() as though they have the same navigation behavior
Why it failsA focused lookup displays documentation for a specific function and returns automatically, while
help()without arguments opens a browsable and searchable interface.Do this insteadUse an argument for a quick, specific lookup and no argument for interactive browsing.
Common mistake Assuming the help system can only explain other functions
What it looks likeNot considering help itself as a possible topic
Why it failsThe help system is self-documenting and can be used to learn about its own capabilities and navigation.
Do this insteadUse help(help) for focused information about help, or enter help() to explore the help system interactively.
Common mistake Leaving the interpreter to look up every small question
What it looks likeOpening external documentation before trying the built-in help system for a quick lookup
Why it failsThe built-in help system provides immediate documentation inside the interpreter and does not require an internet connection.
Do this insteadTry help() for a fast answer about a specific function, statement, or object; use broader tutorials or online documentation when you need more extensive teaching.
| Form | Purpose | What happens next |
|---|---|---|
| help('function_name') | Request documentation about one specific function | Documentation is displayed and the interpreter prompt returns automatically |
| help() | Enter interactive help to browse and search for topics | The help interface remains active until you press q |
| help(help) | Request focused information about the help system itself | It follows the focused-lookup pattern and returns to the prompt automatically |
The presence or absence of an argument determines whether help performs a focused lookup or opens interactive help.
Practice the Prompt-to-Help Cycle
Imagine that you are working at the Python prompt. Decide which help form you would use in each situation: you want quick documentation about one function; you want to browse and search for topics; you want to learn about the help system itself; or you are finished browsing and want to return to Python.
Hints
- A focused lookup includes an argument.
- Interactive browsing starts with no argument.
- The help system can be supplied as its own topic.
- The interactive interface is exited with q.
What do you think happens?
You enter help() with no argument and finish reading one topic. What must you do before normal Python input is available again?
Reveal answer
Press q
The no-argument form enters interactive help mode, and q exits that interface and returns you to the normal Python prompt.
Working Habits to Keep
Use the argument form for a quick lookup when you already know what you want to investigate. Use the no-argument form when you need to browse or search. If you enter interactive help, remember that q is the route back to the Python prompt. Treat help() as an immediate in-interpreter reference, while recognizing that broader tutorials or online documentation may be more appropriate for detailed explanations, examples, or wider concepts.
- 1The built-in
help()function keeps documentation close to your Python work. Passing an argument requests focused documentation and returns you to the prompt automatically. Callinghelp()without an argument opens an interactive interface for browsing and searching, and q exits that interface. Because the help system is self-documenting,help(help)can provide focused information about help itself.
Key Takeaways
- Use
help('function_name')for focused documentation about a specific function. - Use
help()without arguments to enter interactive help mode for browsing and searching. - Press q to exit interactive help and return to the normal Python prompt.
- Use
help(help)to request focused information about the help system itself. - Use
help()for immediate lookups during interpreter work, while using broader tutorials when you need more extensive explanations.