Using a debugger 
 How to debug 
       A recipe for program writing and debugging 
       Application of the recipe 
       Getting help from a code analyzer 
 References 
Testing a program to find errors usually takes much more time than to write the code. This document is devoted to tools and good habits for effective debugging. The section Using a debugger describes the Python debugger, a key tool for examining the internal workings of a code, while the section How to debug explains how to solve problems and write software to simplify the debugging process.
This chapter is taken from book A Primer on Scientific Programming with Python by H. P. Langtangen, 4th edition, Springer, 2014.