Edit history

Edit: -1 of 1
Time: 2007-01-20 22:00:46
Note: /dabosite/wiki/Pdb/reparent

changed:
-
The **pdb** (for 'p'ython 'd'e'b'ugger) module enables you to step through executing code, pausing at each line, or running to pre-set breakpoints. Docs are at http://python.org/doc/2.4.1/lib/module-pdb.html. If you're on Windows, make sure that you run 'python' and not 'pythonw', or you won't see the output.

**pdb** is certainly low level, but after using it a bit you should be able to figure out how to get around pretty well. If you have a section of code you want to step through, add these two lines::

 import pdb
 pdb.set_trace()

That's the equivalent to the VFP **'SET STEP ON'** command, for those of you who are VisualFoxPro users. From that point, execution halts until you tell it how to proceed. The main keys and their Fox equivalents are:

- s - Step Into

- n - Step Over

- u - Step Out

- b NNN - sets a breakpoint at line 'NNN'

- c - Run (until the next breakpoint is reached)

Any time execution stops, you can issue Python commands to check the values of variables, properties, etc., or even change them.