473,383 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 1197
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: Erik Johnson | last post by:
This is somewhat a NEWBIE question... My company maintains a small RDBS driven website. We currently generate HTML using PHP. I've hacked a bit in Python, and generally think it is a rather...
3
by: Dustin Lee | last post by:
I'm wondering if there is a way to get python to show each line as it is executed, sort of like sh -x does for shell programs. Seems like this would be a nice debugging aid. dustin
20
by: Ilias Lazaridis | last post by:
" A cooperation between Sun Microsystems and IBM&Co. in conjunction with liberal & high evolutive communities would result in an nearly unbeatable programming platform. My evaluation has shown:...
68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
0
by: peter | last post by:
Hello all, I would like to debug my python libraries, written in c++, with GDB (gnu debugger) I'm using the mingw compiler in a windows environment. As development environment I use eclipse...
20
by: krypto.wizard | last post by:
Is there any editor or IDE in Python (either Windows or Linux) which has very good debugging facilites like MS VisualStudio has or something like that. I like SPE but couldn't easily use winPDP....
267
by: Xah Lee | last post by:
Python, Lambda, and Guido van Rossum Xah Lee, 2006-05-05 In this post, i'd like to deconstruct one of Guido's recent blog about lambda in Python. In Guido's blog written in 2006-02-10 at...
8
by: Derek Martin | last post by:
I'd like to know if it's possible to code something in Python which would be equivalent to the following C: ---- debug.c ---- #include <stdio.h> bool DEBUG;
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.