ipython
IPython is an interactive Python shell (among other things).
Commands
Extracted from a great series of videos about IPython by Jeff Rush. It's definitely not an exhaustive reference of IPython commands, but rather a quick reference of most frequently used ones.
Part I
| Command | Description |
|---|---|
| who | list all available variables |
| who int | list available integers |
| whos | print detailed listing of available variables |
| psearch | search variable by name |
| psearch msg* | list variables that start with 'msg' |
| store | store variable for next session |
| store -r | restore stored variables |
| store -z | clear storage |
| reset | clear namespace |
| Command | Description |
|---|---|
| logstate | show if logging is activated |
| logstart | activate auto-logging |
| logoff | temporarily disable logging |
| logon | re-enable logging |
| Command | Description |
|---|---|
| lsmagic | list available magic functions |
| magic | show scrolling help about magic commands |
| Command | Description |
|---|---|
| pdef funcname | print definition of function funcname |
| pdoc funcname | print documentation for function funcname |
| pinfo funcname | two of the above combined |
| psource funcname | print source of function funcname |
| pfile funcname | print contents of the file where funcname is defined |
| edit -x re.match | open up the file where re.match is defined for editing in an external editor, but do not execute the code |
| p | short for print |
| page objname | print the object and run it through the pretty printer |
| autoparens | when turned on, allows to type foo 4, 5 to call function foo, so foo 4, 5 <=> foo(4, 5) |
Part II
| Command | Description |
|---|---|
| pwd | print current directory |
| cd | change current directory |
| pushd, popd | push directory onto the stack, remove and cd to the top directory on the stack |
| dirs | print stack of pushed directories |
| bookmark | bookmark current directory |
| bookmark btree | bookmark current directory as btree |
| bookmark myhome /home/fred | bookmark /home/fred as myhome |
| dhist | print directory history |
| !ls | execute ls on an underlying system shell |
| !ls -l $patt | print a long listing of files that match pattern patt, which is a python variable |
| alias | display IPython aliases |
Part III
| Command | Description |
|---|---|
| hist | display command history |
| edit 1-4 | edit history commands 1-4 |
| save apple 1-3 5 | save some commands from history to apple.py |
| edit _i163 | edit definition of a function that was defined on line 163 |
| cpaste | prepare the interpreter for pasting Python source |
| cpaste foo | assign pasted block to variable 'foo' as string |
Part IV
| Command | Description |
|---|---|
| xmode Plain|Context|Verbose | set exception reporting mode |
| xmode | toggle exception reporting mode, cycling through possible mode above |
| pdb | turn on automatic calling of pdb debugger |
| run -d | run something inside a debugger |
| debug | go into debugger explicitly |
| time | time the execution of a command |
| timeit | measure execution time more precisely (for commands that don't take long to execute) |
| prun | run Python profiler system (runs expressions) |
| bg | run expression in the background |
| jobs | print list of background jobs |
Part V
| Command | Description |
|---|---|
| ipython -p physics | run IPython and load the physics profile |
| ipython -pylab | run matplotlib-based Python environment |