Python Help() function is called the built-in Python help system. It displays the documentation of modules, functions, classes, keywords, etc.
help(object)
Help() function in Python
A simple example code checks the documentation of the print function in the Python console.
help(print)
Output:
No argument is passed to help()
help('random thing')
info = help() # No argument
print(info)
Output:
No Python documentation found for ‘random thing’.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
Welcome to Python 3.10’s help utility!
Basic Usage
General Help: Typing help()
in the Python interpreter without any arguments will enter the help system, an interactive help utility where you can type in various commands to get information.
help()
Specific Object: To get help on a specific object (such as a function, class, or module), pass the object or its name (as a string) to help()
.
help(print) # Get help on the built-in print function
help(str) # Get help on the string class
help('os') # Get help on the os module (by name)
Modules: You can get help on entire modules as well. For instance:
import math
help(math)
Keywords: You can use help()
to get information about Python keywords.
help('for')
help('if')
Summary
- General Help:
help()
- Object-Specific Help:
help(object)
orhelp('object_name')
- Module Help:
help(module_name)
- Keyword Help:
help('keyword')
- Interactive Help System:
help()
followed by typing commands within the help system
Do comment if you have any doubts or suggestions on this Python function topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
hello my Friends