This is a draft cheat sheet. It is a work in progress and is not finished yet.
Command Line Options
ipython |
Open IPython terminal console |
ipython qtconsole |
Open IPython qtconsole |
ipython notebook |
Open IPython Notebook (browser interface) |
ipython notebook --pylab inline |
Open IPython Notebook with inline graphs |
Inspection
obj?, obj?? |
Get help, or more help for object |
?obj, ??obj |
Same as above |
?foo.abc |
List names in 'foo' containing 'abc' in them. |
%magic |
Information about magic functions |
%quickref |
Print quick guide to relevant IPython (console, notebook, qtconsole) |
Shortcuts
Tab |
Code and path completion. Second TAB allows cycling through options. |
Ctrl + Enter [qtconsole] |
Allows entering multiple statements (Cell mode) |
Shift + Enter |
Executes current cell |
Ctrl + R [shell] |
Reverser history search (All readline shortcuts are supported) |
|
|
Notebook Magics
%%javascript |
Run code below as javascript |
%%html |
Display markup below as html |
Executing Code
%time or %%time |
Run and output time statement or block (first line for block is setup) |
%prun %%prun |
Profile statement or block |
%run |
Run a file and import resulting variables into namespace |
%%script <executable> |
Run code below using <executable>. --bg runs code in backgrounf and returns Popen object |
%%ruby, %%perl, %%bash |
Shortcuts for %%script <ruby|perl|bash> |
!<cmd> |
Run shell command and return output |
%sh <cmd>, !!<cmd |
Run command and capture output as a list of lines |
%%capture |
Run code in cell and capture stderr and stdout |
|
|
File System Magics
cd, ls, mkdir |
Aliases for python commands with the same functionality |
%bookmark |
Name current folder. Note that cd <bookmark> will work. |
%dhist, _dh |
Display directory history |
%pushd, %popd |
Save| Restore current directory |
%pycat |
Display python source with syntax highlighting |
%%writefile |
Write the text below to a file |
Console and Output Magics
%logstart, %logstop |
Start|Stop saving commmands into a file (by default IPython.py) |
%less |
Run command output through pager |
%pprint |
Toggle automatic pretty printing |
%history |
Output command history |
%recall <num> |
Re executed command #num from history |
%tb |
Print latest Traceback |
%alias |
Name statements for later use. |
_ |
Get result of last statement. Use _i, _ii,_iii to get back in history. Use _<num> for going back to a result of a specific line in history. |
|