Debugging with IPython
Debugging is one of those things nobody really likes, but is very important to master. It can take hours, and because of Murphy's law, you most likely, don't have that time. Therefore, it is important to be systematic and know your tools well. After you are done finding the bug and implementing a fix, you should have a test in place. This way at least you will not have to go through the hell of debugging again. Unit testing is covered in the next chapter. We will debug the following buggy code, which tries to access an array element that is not present:
import numpy a = numpy.arange(7) print a[8]
The IPython debugger works as the normal Python pdb
debugger; it adds features such as tab completion and syntax highlighting.
How to do it...
The following steps illustrate a typical debugging session:
Run the buggy script in IPython.
Start the IPython shell. Run the buggy script in IPython by issuing the following command:
In [1]: %run buggy.py ------------------------------...