© Kristian Rother 2017

Kristian Rother, Pro Python Best Practices, 10.1007/978-1-4842-2241-6_5

5. Debugging with print Statements

Kristian Rother

(1)Berlin, Germany

I see a darkness.

—Will Oldham, also performed by Johnny Cash

In the previous three chapters, we have seen a zoo of program errors and the defects causing them. We have learned about error propagation and the scientific method as a general approach to eliminate bugs. How can we put this knowledge into practice? In this and the following chapters, we will gather tools to diagnose programs in order to find defects. In this chapter, we start with a very simple yet powerful diagnostic tool: print.

The code we will diagnose is drawing the in-game graphics. We will draw the mazes we generated ...

Get Pro Python Best Practices: Debugging, Testing and Maintenance 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.