python debugging question

Discussion in 'Python' started by diffuser78@gmail.com, Mar 8, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Xavier Morel Guest

    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.
    Xavier Morel, Mar 8, 2006
    #2
    1. Advertising

  3. P Boy Guest

    P Boy, Mar 8, 2006
    #3
  4. Harry George Guest

    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
    Harry George, Mar 9, 2006
    #4
  5. Magnus Lycka Guest

    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/thinki.cgi/SoftwareTestingWithPython
    http://thinkware.se/epc2004test/log.html
    Magnus Lycka, Mar 16, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johann Blake
    Replies:
    1
    Views:
    1,186
    Hermit Dave
    Jan 5, 2004
  2. Bill Loren

    Debugging Python ?

    Bill Loren, Jul 28, 2003, in forum: Python
    Replies:
    2
    Views:
    330
    Syver Enstad
    Aug 2, 2003
  3. Michael Sparks

    Re: Debugging Python ?

    Michael Sparks, Jul 28, 2003, in forum: Python
    Replies:
    14
    Views:
    471
    Trent Mick
    Jul 29, 2003
  4. jacob navia

    Debugging C vs debugging C++

    jacob navia, Oct 26, 2006, in forum: C Programming
    Replies:
    11
    Views:
    573
    Ian Collins
    Oct 27, 2006
  5. AAaron123
    Replies:
    3
    Views:
    645
    AAaron123
    Jul 28, 2009
Loading...

Share This Page