{"id":24662,"date":"2021-10-25T09:12:38","date_gmt":"2021-10-25T03:42:38","guid":{"rendered":"https:\/\/python-programs.com\/?p=24662"},"modified":"2021-11-05T19:44:47","modified_gmt":"2021-11-05T14:14:47","slug":"python-help-function-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-help-function-with-examples\/","title":{"rendered":"Python help() function with Examples | Help function in Python"},"content":{"rendered":"
In the previous article, we have discussed Python String encode() Method with Examples<\/a> The help() method invokes or calls Python’s built-in help system.<\/p>\n The Python help function displays documentation for modules, functions, classes, keywords, and so on.<\/p>\n Syntax:<\/strong><\/p>\n Parameters<\/strong><\/p>\n The help() method only accepts one parameter.<\/p>\n object:<\/strong> This is optional. you want to generate help and support from the given object<\/p>\n For interactive use, the help() method is used. When you need assistance writing Python programs and using Python modules, it is recommended that you try it in your interpreter.<\/p>\n 1)Note: It should be noted that object is passed to help() (not a string)<\/strong><\/p>\n For Example:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Explanation:<\/strong><\/p>\n similarly, try out for these<\/p>\n If a string is passed as an argument, the name of a module, function, class, method, keyword, or documentation topic is printed, as well as a help page.<\/p>\n 2)Note: It should be noted that string is passed as an argument to help()<\/strong><\/p>\n When a string is passed as an argument, it is looked up as the name of a module, function, class, method, keyword, or documentation topic and a help page is printed.<\/p>\n Check it out for the following Examples.<\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n similarly, try out for these<\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n 3)Note: It should be noted that no argument is passed to help()<\/strong><\/p>\n If no arguments are provided, Python’s help utility (interactive help system) is launched on the console.<\/p>\n Then, enter the topic name to get help with writing Python programmes and using Python modules.<\/p>\n As an example, Check it out for the following Examples:<\/p>\n To return to the interpreter and exit the help utility, type quit and press enter.<\/p>\n Find a Comprehensive Collection of Python Built in Functions<\/a> that you need to be aware of and use them as a part of your program.<\/p>\n In the previous article, we have discussed Python String encode() Method with Examples help() Function in Python: The help() method invokes or calls Python’s built-in help system. The Python help function displays documentation for modules, functions, classes, keywords, and so on. Syntax: help(object) Parameters The help() method only accepts one parameter. object: This is optional. …<\/p>\n
\nhelp() Function in Python:<\/strong><\/p>\nhelp(object)<\/pre>\n
help(list)<\/pre>\n
Help on class list in module builtins:\r\n\r\nclass list(object)\r\n | list() -> new empty list\r\n | list(iterable) -> new list initialized from iterable's items\r\n | \r\n | Methods defined here:\r\n | \r\n | __add__(self, value, \/)\r\n | Return self+value.\r\n | \r\n | __contains__(self, key, \/)\r\n | Return key in self.\r\n | \r\n | __delitem__(self, key, \/)\r\n | Delete self[key].\r\n | \r\n | __eq__(self, value, \/)\r\n | Return self==value.\r\n | \r\n | __ge__(self, value, \/)\r\n | Return self>=value.\r\n | \r\n | __getattribute__(self, name, \/)\r\n | Return getattr(self, name).\r\n | \r\n | __getitem__(...)\r\n | x.__getitem__(y) <==> x[y]\r\n | \r\n | __gt__(self, value, \/)\r\n | Return self>value.\r\n | \r\n | __iadd__(self, value, \/)\r\n | Implement self+=value.\r\n | \r\n | __imul__(self, value, \/)\r\n | Implement self*=value.\r\n | \r\n | __init__(self, \/, *args, **kwargs)\r\n | Initialize self. See help(type(self)) for accurate signature.\r\n | \r\n | __iter__(self, \/)\r\n | Implement iter(self).\r\n | \r\n | __le__(self, value, \/)\r\n | Return self<=value.\r\n | \r\n | __len__(self, \/)\r\n | Return len(self).\r\n | \r\n | __lt__(self, value, \/)\r\n | Return self<value.\r\n | \r\n | __mul__(self, value, \/)\r\n | Return self*value.\r\n | \r\n | __ne__(self, value, \/)\r\n | Return self!=value.\r\n | \r\n | __new__(*args, **kwargs) from builtins.type\r\n | Create and return a new object. See help(type) for accurate signature.\r\n | \r\n | __repr__(self, \/)\r\n | Return repr(self).\r\n | \r\n | __reversed__(...)\r\n | L.__reversed__() -- return a reverse iterator over the list\r\n | \r\n | __rmul__(self, value, \/)\r\n | Return value*self.\r\n | \r\n | __setitem__(self, key, value, \/)\r\n | Set self[key] to value.\r\n | \r\n | __sizeof__(...)\r\n | L.__sizeof__() -- size of L in memory, in bytes\r\n | \r\n | append(...)\r\n | L.append(object) -> None -- append object to end\r\n | \r\n | clear(...)\r\n | L.clear() -> None -- remove all items from L\r\n | \r\n | copy(...)\r\n | L.copy() -> list -- a shallow copy of L\r\n | \r\n | count(...)\r\n | L.count(value) -> integer -- return number of occurrences of value\r\n | \r\n | extend(...)\r\n | L.extend(iterable) -> None -- extend list by appending elements from the iterable\r\n | \r\n | index(...)\r\n | L.index(value, [start, [stop]]) -> integer -- return first index of value.\r\n | Raises ValueError if the value is not present.\r\n | \r\n | insert(...)\r\n | L.insert(index, object) -- insert object before index\r\n | \r\n | pop(...)\r\n | L.pop([index]) -> item -- remove and return item at index (default last).\r\n | Raises IndexError if list is empty or index is out of range.\r\n | \r\n | remove(...)\r\n | L.remove(value) -> None -- remove first occurrence of value.\r\n | Raises ValueError if the value is not present.\r\n | \r\n | reverse(...)\r\n | L.reverse() -- reverse *IN PLACE*\r\n | \r\n | sort(...)\r\n | L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*\r\n | \r\n | ----------------------------------------------------------------------\r\n | Data and other attributes defined here:\r\n | \r\n | __hash__ = None\r\n<\/pre>\n
In this way we get the output which displays the documentation for modules, \r\nfunctions, classes, keywords, and so on.<\/pre>\n
>>help(dict)\r\n>>help(print)\r\n>>help(tuple)\r\n>>help([4,5,6])<\/pre>\n
help('hello')<\/pre>\n
No Python documentation found for 'hello'.\r\nUse help() to get the interactive help utility.\r\nUse help(str) for help on the str class.\r\n<\/pre>\n
>>help('print')\r\n>>help('uvw')<\/pre>\n
from math import * \r\nhelp('math.pow')<\/pre>\n
Help on built-in function pow in math:\r\n\r\nmath.pow = pow(...)\r\n pow(x, y)\r\n \r\n Return x**y (x to the power of y).\r\n<\/pre>\n
>>help()<\/pre>\n
help > True\r\nhelp > 'print'\r\nhelp > print<\/pre>\n
help > quit<\/pre>\n
\n