Sometime is useful to be able to understand what is going on inside a function or a class. Python in the standar library has a package pdb, that integrate python with a debugger.
Ipython notebook at the moment is not able to manage pdb from the browser, so you should use caling your program from a shell.
Note: Spyder integrate a python debugger in the GUI.
You can execute line by line a python file with:
python -m ipdb mymodule.py
Or you can call ipdb at certain point of your code adding the line
import ipdb; ipdb.set_trace()
Other common functions are:
import ipdb ipdb.set_trace() ipdb.pm() ipdb.run('x = 3') result = ipdb.runcall(function, arg0, arg1, kwarg='foo') result = ipdb.runeval('f(1, 2) - 3')
Or you can said to open a ipdb shell when an exception is raised, with:
from ipdb import launch_ipdb_on_exception with launch_ipdb_on_exception(): [...]
Once that you are inside a ipdb shell you have several commands that you can run, type h for the help: