debugging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug Farrell

    debugging

    Hi all,

    Can someone help me out a little with Python? What do people use to
    debug Python code? I don't understand how to use the built in debugger
    and I haven't had any luck getting ddd to debug my Python programs. I
    end up falling back on inserting print statements in my code to figure
    out what's going on. This works but isn't always the fastest route to
    a solution. So, I'm just wondering what other people do.

    Thanks,
    Doug
  • Diez B. Roggisch

    #2
    Re: debugging

    Hi,
    [color=blue]
    > Can someone help me out a little with Python? What do people use to
    > debug Python code? I don't understand how to use the built in debugger
    > and I haven't had any luck getting ddd to debug my Python programs. I
    > end up falling back on inserting print statements in my code to figure
    > out what's going on. This works but isn't always the fastest route to
    > a solution. So, I'm just wondering what other people do.[/color]

    I use print..... But if you want to have a graphical debugger, look into
    eric. Actually, its much more, and if I were not so tied to xemacs key
    bindings, I'd switch yesterday.

    Diez

    Comment

    • Michael Hudson

      #3
      Re: debugging

      writeson@earthl ink.net (Doug Farrell) writes:
      [color=blue]
      > Hi all,
      >
      > Can someone help me out a little with Python? What do people use to
      > debug Python code? I don't understand how to use the built in
      > debugger[/color]

      What have you tried? pdb.run('...') and pdb.set_trace() may be your
      friends.
      [color=blue]
      > and I haven't had any luck getting ddd to debug my Python programs. I
      > end up falling back on inserting print statements in my code to figure
      > out what's going on. This works but isn't always the fastest route to
      > a solution. So, I'm just wondering what other people do.[/color]

      Well, quite a lot of the time I ... insert print statements in my
      code.

      I also find stopping and actually thinking hard every now and again
      helps, too :-)

      Cheers,
      mwh

      --
      ARTHUR: Yes. It was on display in the bottom of a locked filing
      cabinet stuck in a disused lavatory with a sign on the door
      saying "Beware of the Leopard".
      -- The Hitch-Hikers Guide to the Galaxy, Episode 1

      Comment

      • Larry Bates

        #4
        Re: debugging

        Doug,

        I use a loggerclass to log debugging/tracing information
        to a log file during the program execution. I trigger these
        logging statements by setting python variables _trace and
        _debug at the top of my program execution (normally by reading
        them from a .INI file using ConfigParser). This way I can
        trace/debug my program and then easily turn them off when
        the code is finalized. I leave this code in the application
        and find that it can prove to be very valuable should a
        problem arise in the future. Just turn on trace/debug and
        take a look at the log file. I don't believe that there
        is significant overhead in a few "if _debug: logf.writelines ..."
        statements in the code.

        -Larry


        "Doug Farrell" <writeson@earth link.net> wrote in message
        news:88bc63c6.0 401230416.7acf9 04c@posting.goo gle.com...[color=blue]
        > Hi all,
        >
        > Can someone help me out a little with Python? What do people use to
        > debug Python code? I don't understand how to use the built in debugger
        > and I haven't had any luck getting ddd to debug my Python programs. I
        > end up falling back on inserting print statements in my code to figure
        > out what's going on. This works but isn't always the fastest route to
        > a solution. So, I'm just wondering what other people do.
        >
        > Thanks,
        > Doug[/color]


        Comment

        • Michael Geary

          #5
          Re: debugging

          Doug Farrell wrote:[color=blue]
          > Can someone help me out a little with Python? What do people
          > use to debug Python code? I don't understand how to use the
          > built in debugger and I haven't had any luck getting ddd to
          > debug my Python programs. I end up falling back on
          > inserting print statements in my code to figure out what's
          > going on. This works but isn't always the fastest route to a
          > solution. So, I'm just wondering what other people do.[/color]

          What OS are you running?

          On Windows, PythonWin has a nice interactive debugger.

          My favorite is Komodo, which is available for Windows, Linux, and Solaris:



          Komodo is not free, but the personal edition is pretty cheap, and the
          commercial edition is well worth the price for commercial development.

          -Mike


          Comment

          • Hans Nowak

            #6
            Re: debugging

            Doug Farrell wrote:[color=blue]
            > Hi all,
            >
            > Can someone help me out a little with Python? What do people use to
            > debug Python code? I don't understand how to use the built in debugger
            > and I haven't had any luck getting ddd to debug my Python programs. I
            > end up falling back on inserting print statements in my code to figure
            > out what's going on. This works but isn't always the fastest route to
            > a solution. So, I'm just wondering what other people do.[/color]

            "The most effective debugging tool is still careful thought, coupled with
            judiciously placed print statements." -- Brian Kernighan (1978)

            The 'print statements' method still works, anno 2004. Aside from that, I use
            unit tests. I never use a debugger; I find stepping through code, or breaking
            execution off halfway, rather clumsy.

            Just my $0.02,

            --
            Hans (hans@zephyrfal con.org)
            Memimpin Angin Perubahan Teknologi




            Comment

            • python newbie

              #7
              Re: debugging

              I second the recommend. on Komodo. I'm definitely happy with it myself. I
              recently bought the personal edition.
              If you install the ActiveState version, as you heard by now, you get
              PythonWin which can debug. I notice the similarity in interfaces even, as
              they were both made by ActiveState of course. However Komodo has a lot of
              functionality beyond it, if you need that it is (if you even care about
              Komodo and what I'm typing here, bye).

              "Michael Geary" <Mike@DeleteThi s.Geary.com> wrote in message
              news:1012jf28ch jio61@corp.supe rnews.com...[color=blue]
              > Doug Farrell wrote:[color=green]
              > > Can someone help me out a little with Python? What do people
              > > use to debug Python code? I don't understand how to use the
              > > built in debugger and I haven't had any luck getting ddd to
              > > debug my Python programs. I end up falling back on
              > > inserting print statements in my code to figure out what's
              > > going on. This works but isn't always the fastest route to a
              > > solution. So, I'm just wondering what other people do.[/color]
              >
              > What OS are you running?
              >
              > On Windows, PythonWin has a nice interactive debugger.
              >
              > My favorite is Komodo, which is available for Windows, Linux, and Solaris:
              >
              > http://www.activestate.com/Products/Komodo/
              >
              > Komodo is not free, but the personal edition is pretty cheap, and the
              > commercial edition is well worth the price for commercial development.
              >
              > -Mike
              >
              >[/color]


              Comment

              Working...