The pdb module

This is the standard Python debugger. It is based on the bdb debugger framework.

You can run the debugger from the command line. Type n (or next) to go to the next line, help to get a list of available commands.

(Pdb) n
(Pdb) n
hello again, and welcome to the show

You can also start the debugger from inside a program.

Example: Using the pdb module

# File:

import pdb

def test(n):
    j = 0
    for i in range(n):
        j = j + i
    return n

db = pdb.Pdb()
db.runcall(test, 1)

-> def test(n):
(Pdb) s
-> j = 0
(Pdb) s
-> for i in range(n):