Page 425 -
P. 425
exterminating bugs
#5: Debugging
This is not as disgusting as it sounds.
The problem is not with
Debugging is related to testing. It is the process of dealing with the hardware; it‛s with
errors that aren’t picked up during testing but, instead, blow up in your program. You‛ll have
your face when you run your code or—worse—blow up in the face to DEBUG your code.
of your user!
Tracking down where a problem is can sometimes feel like a bit of
an art form, but there are some tried and true techniques that can
make things easier for you. Experience helps a lot.
One of the most important things you can know about when it
comes to debugging code is a thing called the debugger. This is
a software tool that can be used by programmers to run code step
by step or line by line. As the program runs, the debugger lets you
watch what’s going on and then potentially see when something
goes wrong. If you can work out where in your code the problem lies,
it makes it easier to fix, and the debugger is designed to help you do
just that.
It is a rare programming technology indeed that comes without
a debugger. Python’s is called pdb and it can be accessed from
within IDLE and within the Python Shell. Check the Python online
documentation for more information on pdb.
As mentioned at the top of the page: debugging is related to testing.
Typically, you debug your code after it is up and running and
(possibly) delivered to your user. You test your code as you write it
and before you give your program to your users. The idea is that you
only ever give a user your program when you’re happy it works the
way you want it to.
To be honest, though, there are no hard and fast rules here, and a
lot of programmers blur the line between debugging and testing,
treating it all as one activity.
390 appendix i

