1.3.5 Debugger Entry Functions

The pydb module defines the following functions, and each enters the debugger in a slightly different way:

pm( [opts-dictionary=None, cmdfile=None])
Enter post-mortem debugging of the traceback found in sys.last_traceback. Note you may need to have sys imported priort to having the error raised to have sys.last_traceback set.

To set debugger options, pass a dictionary of variable, value pairs that you want set in opts-dictionary. For example if you want the display listsize to be 20 by default on entry pass {listsize: 20}.

post_mortem( traceback[opts-dictionary=None, cmdfile=None])
Enter post-mortem debugging of the given traceback object.

To set debugger options, pass a dictionary of variable, value pairs that you want set in opts-dictionary. For example if you want the display listsize to be 20 by default on entry pass @listsize: 20@.

run( statement[, globals[, locals]])
Execute the statement (given as a string) under debugger control. The debugger prompt appears before any code is executed; you can set breakpoints and type "continue", or you can step through the statement using "step" or "next" See 1.2.3 and 1.2.3 for explanations of these commands. The optional globals and locals arguments specify the environment in which the code is executed; by default the dictionary of the module __main__ is used. (See the explanation of the exec statement or the eval() built-in function.)

runcall( function[, argument, ...])
Call the function (a function or method object, not a string) with the given arguments. When runcall() returns, it returns whatever the function call returned. The debugger prompt appears as soon as the function is entered.

runeval( expression[, globals[, locals]])
Evaluate the expression (given as a string) under debugger control. When runeval() returns, it returns the value of the expression. Otherwise this function is similar to run().

set_trace( [cmdfile=None])
Enter the debugger at the calling stack frame. This is useful to hard-code a breakpoint at a given point in a program, even if the code is not otherwise being debugged (e.g., when an assertion fails).

When the debugger is quitting, this causes the program to be terminated. If you want the program to continue instead, use the debugger function.

See About this document... for information on suggesting changes.