Getting help in IPython

IPython has an in-depth integrated help system. You can get help on IPython’s magic functions, view documentation from a single function, check out syntax-highlighted source code, or enter the Python interactive help system. Here’s a list of the commands to use.

lsmagic lists the magic commands
? (at the end of a function or variable) show help
?? (at the end of a function or object) show detailed help; often includes source code
help(sys) online documentation for the sys module (sys must be imported first)
help(’for’) online doc for the for
keyword
help() enters the help system
topics (at the help prompt) lists help topics.  Type
one to view it.
q (at the help prompt) Exit the help
system.

 
Import the re module (regular expression module) as an example for the commands below:

import re
pdef re.match just the initialization expression for the re.match function
pdoc re.match just the help text for re.match
pinfo re.match same as using re.match?
(shows help)
psource re.match same as using re.match??
(shows detailed help)
pfile re.match shows the contents of the file where the function
is defined
pycat scriptName displays the file, scriptName, in syntax-highlighted text
edit -x re.match opens the source file for re.match in default editor

Tags: , , ,

Leave a Reply