4.3. Debugging¶
the relationship between debugging and testing
reason for debugging: trying to pin down the root cause of unwanted/unexpected behaviour
reason for testing: specifying the expected behaviour in form of executable code (i.e. tests)
read the error messages of the Python interpreter
Most problems can be solved carefully reading the error messages
usual problem: RTFM
poor man’s debugging: print statements
short-term strategy
not advocating using print statements instead of a debugger, but rather admitting what most people seem to do
tips and tricks how to use it sensibly (finding a lost print statement can be tedious)
convert bugs into tests
see next section on tests and testing for details
use the builtin Python debugger pdb
admittedly, I have never used it myself
see the official documentation for details