Simple debugging tricks and techniques

We saw the power of the simple print statement in the previous example. In a similar way, other simple techniques can be used to debug programs without requiring to resort to a debugger.

Debugging can be thought of as a step-wise process of exclusion until the programmer arrives at the truth—the cause of the bug. It essentially involves the following steps:

  • Analyze the code and come up with a set of probable assumptions (causes) that may be the source of the bug.
  • Test out each of the assumptions one by one by using appropriate debugging techniques.
  • At every step of the test, you either arrive at the source of the bug—as the test succeeds telling you the problem was with the specific cause you were testing for; ...

Get Software Architecture with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.