python debugging question

D

diffuser78

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
 
X

Xavier Morel

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
Check the PDB standard package, reading Debugging in Python
(http://www.ferg.org/papers/debugging_in_python.html) may also help.

And I think SPE provides WinPDB, check the user manual.

I'd suggest trying to work out why it doesn't work at a higher level
instead of relying on the debugger already, 500 lines is not much code
to go through, a few well placed prints or sys.stderr.write() should be
more than enough.
 
H

Harry George

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:
http://www.seanet.com/~hgg9140/comp/index.html#L006
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.
 
M

Magnus Lycka

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.

If you first write 500 lines of code, and *then* try to run it,
it seems you are using a development approach suitable in the
1960's when running a program meant handing a stack of punch
cards to a computer operator in a white coat, and then getting
the result of the run the next day (if you're lucky).

I was taught to write like this as recently as in the late 80's
when I was in universtity, but today I typically run my code
every ten minutes or so. It's rare that I run the code I work
on less frequently than every thirty minutes.

In my experience, my current way of developing software leads to
higher productivity, better quality and much better predictability
in regards to both development time and software performance and
features. The way to achieve this is to use lots of automated
tests and a development time where you learn to work in small
increments. Martin Fowler's book "Refactoring" is a good guide
for this, and Python is a very good language to use for this kind
of development.

Perhaps this might be useful?
http://www.thinkware.se/cgi-bin/thinki.cgi/SoftwareTestingWithPython
http://thinkware.se/epc2004test/log.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top