liveBook · Manning

Debugger

As explained in Get Programming: Learn to code with Python

A software tool that pauses program execution and exposes execution state, such as variable values, while code runs.

A debugger pauses a running program so you can inspect variable values one step at a time. It reports what the program is doing; you still decide which line is wrong. section 36.3

A simple debugging routine is:

  • Choose the failing test and place a breakpoint where its execution begins. section 36.3
  • Start debugging, then step through the code while watching the variable values. section 36.3
  • Explain each line in plain English and remain skeptical, even when the line looks simple. section 36.3

Tracing a failed test

For a failing test of absolute_value(0), set a breakpoint before the function call and step through its conditionals. The debugger reveals the current line and values, helping you notice that the function handles n < 0 and n > 0 but needs attention when n equals zero. section 36.3

Figure 36.1. Screenshot of the debugging window

Use the debugging-window screenshot to connect the editor, console, variable explorer, breakpoint, and current execution line. section 36.3

How Get Programming: Learn to code with Python covers it

How deep it goes
Explains breakpoints, debugging mode, stepping, and variable inspection, while leaving the programmer to identify the incorrect line.
Examples
Demonstrates Spyder debugging with failed absolute-value and prime-number tests, including breakpoint and conditional-tracing listings.
What it assumes
Assumes runnable code and a failing test; teaches breakpoint-based inspection and plain-language line tracing.
What you can do after
Diagnose failing code by setting breakpoints, stepping through execution, and inspecting variable values.
How it connects
Connects debugging with unit testing, breakpoints, variable values, and line-by-line code tracing.

Also explained in

Compare how 6 books explain debugger →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Get Programming: Learn to code with Python. The section links point to the parts of the book it draws on.