python debugging question

Harry George at
Thu Mar 9 15:25:25 CET 2006

diffuser78 at writes:

> I am a python newbie. I have writen some 500 lines of code. There are 4
> classes and in all 5 files.
> Now, I am trying to run the program. I am getting wrong values for the
> simulation results.
> Is there any debugging facilities in python which would let me go step
> by step and check the values of the variables at every step. I have
> done something like this in MS Visual Stdio 6.0 sometime back.
> For python, I am using SPE.
> what is a good way of debugging such large and iterative programs ? Any
> tips.
> Every help is appreciated.
> Thanks
If you use my mkpythonproj:
then you will have a test suite and a "debug" ftn ready to go.

For a brand new project, where you are exploring and don't know what
the test cases might be, you can just do the debug calls. Once you
know where you are headed (or if you got rqmts at the start) then
crank up some test cases and run that testsuite everytime you add a
few lines of code.

Start exploring or testing at the "hello, world" level, and gradually
add functionality (tests and code) as you go.  This is MUCH easier
than writing a lot of code and then trying to debug it.  You only need
to understand a few lines at a time.

In tens of thousands of lines of python code, I think I've used a
debugger (pdb) maybe once.  We have some apps here that are one-off
quick hacks and others that are multi-person, multi-year efforts.
They all live by their test suites.

Harry George
PLM Engineering Architecture

More information about the Python-list mailing list