[Tutor] [tutor] debug process
Dave Kuhlman
dkuhlman at rexx.com
Tue Jun 13 17:45:28 CEST 2006
On Tue, Jun 13, 2006 at 08:51:49AM +0200, Wolfram Kraus wrote:
> emilia12 at mail.bg schrieb:
> > Hello,
> >
> > Is there a way to debug (trace) the python code line by line?
> >
> > emily
> >
>
> Hi emily!
>
> You can use The Python Debugger or pdb, see:
> http://www.python.org/doc/2.4.2/lib/module-pdb.html
>
Also, put the following at the location in your code where you
want to drop into the debugger:
import pdb
pdb.set_trace()
and then, at the pdb prompt, type:
(Pdb) help l
(Pdb) help b
etcetera.
You can also do:
import pdb
pdb.help()
which will show you documentation on pdb.
And, this is not a debugger but ... If you have installed
IPython, you can also easily embed a complete Python interpreter
in your program. Although it does not give you breakpoints and
other debugging features, it does enable you to do lots in the way
of inspecting objects, evaluating objects, performing tests on
objects, etc.
If you have *not* installed IPython, I recommend it. It makes a
great replacement for the standard Python interactive interpreter.
To learn about IPython, see:
IPython:
http://ipython.scipy.org/
Embedding IPython:
http://ipython.scipy.org/doc/manual/node9.html
Using the Python debugger (pdb) (with IPython):
http://ipython.scipy.org/doc/manual/node10.html
Dave
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
More information about the Tutor
mailing list