your favorite debugging tool?

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Aug 24 13:33:07 CEST 2009


Esmail wrote:
> Hi all,
>
> What is your favorite tool to help you debug your
> code? I've been getting along with 'print' statements
> but that is getting old and somewhat cumbersome.
>
> I'm primarily interested in utilities for Linux (but
> if you have recommendations for Windows, I'll take
> them too :)
>
> I use emacs as my primary development environment, FWIW.
> Someone mentioned winpdb .. anyone have experience/comments
> on this? Others?
>
> Thanks,
> Esmail
>
I execute the program within IPython.
 >>> run test.py

I usually write a CTRL+C except clause that will spawn an Ipython shell 
so I can inspect the namespace at that time.
I'm also using the ipdb to spawn the debugger.

import IPython
ipdb = IPython.Debugger.Pdb(color_scheme='Linux')
ipdb.set_trace()

it spawns the IPython debugger, allowing step by step execution, code 
inspection, changing the namespace. You get all the IPython benefits 
(espacially the TAB completion, history ...)

I used to proceed with print statements, but they are some situations 
where it won't just make it. Sometimes the code is so complex you can't 
anticipate all the required prints to catch a bug.

JM



More information about the Python-list mailing list