Content · Programming · Python

Python pdb Commands: next, step, continue, and quit

pdb commands n, s, c and q mean next line, step into a call, continue execution and quit debugging.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

pdb commands n, s, c and q mean next line, step into a call, continue execution and quit debugging.

Understanding the Concept


pdb commands n, s, c and q mean next line, step into a call, continue execution and quit debugging.

Commands that require a live pdb prompt are explained but are intentionally not launched by this example.

How this helps diagnose real applications


First decide what question you are trying to answer: whether a particular branch runs, why an operation failed, or what contextual event should be recorded. Logging, interactive debugging, traceback inspection and controlled timing complement each other but produce different kinds of evidence.

Diagnostic output should preserve enough context to reproduce the problem without recording passwords, tokens, full personal records or untrusted payloads. Keep instrumentation focused so it does not hide the original behavior.

Worked Example


Read the code from the first line to the last. Identify which values are inputs, which operation is being demonstrated and what should happen before running it.

def cube(number):
    return number ** 3

print(cube(3))
# Debug with python -m pdb script.py and try n, s, c and q.

Walkthrough: What Each Part Does


  • The definition cube creates reusable behavior. Its body runs when called, awaited or instantiated; defining it alone does not run the body of an ordinary function.
  • Observe which message or diagnostic field appears and which condition caused it. Modify the input deliberately to test the failure path.

This demonstration focuses on one practical behavior. Before changing several lines, vary one input or one configuration choice and check whether the result changes for the reason you expected.

The example uses terminal, platform, external tool or process behavior that was not exercised automatically. Run it only in a suitable environment after reviewing the shown permissions and paths.

Important Behavior and Edge Cases


Confusing n with s or accidentally quitting before recording the important state.

Commands that require a live pdb prompt are explained but are intentionally not launched by this example.

Practice Exercise


Run the short script in a real terminal debugger and write down the inspected variable before continuing.

Write down the result you expect before running your changed code. Check at least one normal case and one boundary or failure case. If your example starts workers or opens resources, verify how they are cleaned up.

Further reading: official documentation and API reference.

Common Beginner Mistakes


  • Confusing n with s or accidentally quitting before recording the important state.
  • Removing the diagnostic message after seeing it once instead of reproducing the failure and checking the underlying cause.

Key Takeaways


  • pdb commands n, s, c and q mean next line, step into a call, continue execution and quit debugging.
  • Commands that require a live pdb prompt are explained but are intentionally not launched by this example.
  • Practice: Run the short script in a real terminal debugger and write down the inspected variable before continuing.
Share this resourceSend this page to someone who may find it useful.