468,121 Members | 1,353 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,121 developers. It's quick & easy.

python debugging question

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

Mar 8 '06 #1
4 1039
di********@gmail.com wrote:
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.
Mar 8 '06 #2
Install active python from
http://activestate.com/Products/ActivePython/?mp=1
Run PythonWin for: coding, interactive commands, and debugging.

Good luck.

Mar 8 '06 #3
di********@gmail.com 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:
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.

--
Harry George
PLM Engineering Architecture
Mar 9 '06 #4
di********@gmail.com wrote:
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/thin...tingWithPython
http://thinkware.se/epc2004test/log.html
Mar 16 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

34 posts views Thread by Erik Johnson | last post: by
3 posts views Thread by Dustin Lee | last post: by
20 posts views Thread by Ilias Lazaridis | last post: by
68 posts views Thread by Lad | last post: by
20 posts views Thread by krypto.wizard | last post: by
267 posts views Thread by Xah Lee | last post: by
8 posts views Thread by Derek Martin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.