The python help function is used to display the documentation of modules, functions, classes, keywords etc.
The help function has the following syntax:
help([object])
If the help function is passed without an argument, then the interactive help utility starts up on the console.
Let us check the documentation of the print function in python console.
help(print) |
It gives the following output:
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
Help function output can also be defined for user defined functions and classes. The docstring(documentation string) is used for documentation. It is nested inside triple quotes and is the first statement within a class or function or a module.
Let us define a class with functions:
class Helper: def __init__(self): '''The helper class is initialized''' def print_help(self): '''Returns the help description''' print('helper description') help(Helper) help(Helper.print_help) |
On running the above program, we get the output of the first help function as shown below:
Help on class Helper in module __main__:
class Helper(builtins.object)
| Methods defined here:
|
| __init__(self)
| The helper class is initialized
|
| print_help(self)
| Returns the help description
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
Help on function print_help in module __main__:
print_help(self)
Returns the help description
Recommended Posts:
- Python | Add the element in the list with help of indexing
- PyQt5 – What's this help text for Label | setWhatsThis() method
- PyQt5 – Setting and accessing WHATS THIS help text for Status Bar
- PyQt5 – How to create and get the help text of Push Button ?
- PyQt5 - setWhatsThis() help text of Radio button
- PyQt5 - Setting help text of the combo box
- PyQt5 - Accessing help text of the combo box
- PyQt5 QCommandLinkButton - Setting Help Text
- PyQt5 QCommandLinkButton - Getting Help Text
- Python - Call function from another function
- Wand function() function in Python
- Returning a function from a function - Python
- wxPython - GetField() function function in wx.StatusBar
- How to write an empty function in Python - pass statement?
- Function Decorators in Python | Set 1 (Introduction)
- Vulnerability in input() function – Python 2.x
- Function Annotations in Python
- Sorted() function in Python
- Ways to sort list of dictionaries by values in Python - Using lambda function
- Python Numbers | choice() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

