debugging

D

Doug Farrell

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
 
M

Michael Hudson

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

What have you tried? pdb.run('...') and pdb.set_trace() may be your
friends.
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.

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
 
D

Diez B. Roggisch

Hi,
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.

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
 
L

Larry Bates

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
 
M

Michael Geary

Doug said:
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.

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
 
H

Hans Nowak

Doug said:
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.

"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,
 
P

python newbie

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).
 

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
474,176
Messages
2,570,950
Members
47,500
Latest member
ArianneJsb

Latest Threads

Top