Python Programming/Self Help
This book is useful for learning Python, but there might be a topic that the book does not cover. You might want to search for modules in the standard library, or inspect an unknown object's functions, or perhaps you know there is a function that you have to call inside an object but you don't know its name. This is where the interactive help comes into play.
Built-in help overview
Built-in interactive help at a glance:
help() # Starts an interactive help help("topics") # Outputs the list of help topics help("OPERATORS") # Shows help on the topic of operators help("len") # Shows help on len function help("re") # Shows help on re module help("re.sub") # Shows help on sub function from re module help(len) # Shows help on the object passed, the len function help(.pop) # Shows help on the pop function of a list dir() # Outputs a list of attributes of a list, which includes functions import re help(re) # Shows help on the help module help(re.sub) # Shows help on the sub function of re module help(1) # Shows help on int type help() # Shows help on list type help(def) # Fails: def is a keyword that does not refer to an object help("def") # Shows help on function definitions
To start Python's interactive help, type "help()" at the prompt.
You will be presented with a greeting and a quick introduction to the help system. For Python 2.6, the prompt will look something like this:
Welcome to Python 2.6! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://docs.python.org/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam".
Notice also that the prompt will change from ">>>" (three right angle brackets) to "help>" You can access the different portions of help simply by typing in modules, keywords, or topics.
Typing in the name of one of these will print the help page associated with the item in question. To get a list of available modules, keywords, or topics, type "modules","keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam".
You can exit the help system by typing "quit" or by entering a blank line to return to the interpreter.
You can obtain information on a specific command without entering interactive help.
For example, you can obtain help on a given topic simply by adding a string in quotes, such as help("object"). You may also obtain help on a given object as well, by passing it as a parameter to the help function.
- help in 2. Built-in Functions, docs.python.org