The pdb Module

The pdb module 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 and help to get a list of available commands):

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

Example 11-2 shows how to start the debugger from inside a program.

Example 11-2. Using the pdb Module


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):

Core Modules

More Standard Modules

Threads and Processes

Data Representation

File Formats

Mail and News Message Processing

Network Protocols


Multimedia Modules

Data Storage

Tools and Utilities

Platform-Specific Modules

Implementation Support Modules

Other Modules

Python Standard Library
Python Standard Library (Nutshell Handbooks) with
ISBN: 0596000960
EAN: 2147483647
Year: 2000
Pages: 252
Authors: Fredrik Lundh © 2008-2020.
If you may any questions please contact us: