How are the functions help() and dir() different?


These are the two functions that are accessible from the Python Interpreter. These two functions are used for viewing a consolidated dump of built-in functions.

help() - it will display the documentation string. It is used to see the help related to modules, keywords, attributes, etc.
To view the help related to string datatype, just execute a statement help(str) – it will display the documentation for 'str, module.
◦ Eg: >>>help(str) or
>>>help() - it will open the prompt for help as help>
 to view the help for a module, help> module module name
Inorder to view the documentation of 'str' at the help>, type help>modules str
to view the help for a keyword, topics, you just need to type, help> “keywords python-
keyword” and “topics list”
 dir() - will display the defined symbols.
 Eg: >>>dir(str) – will only display the defined symbols.


© 2017