How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

Ed Leafe ed at leafe.com
Tue Jan 26 21:41:33 EST 2021


On Jan 26, 2021, at 18:16, Grant Edwards <grant.b.edwards at gmail.com> wrote:
> 
>> How do you troubleshooting/debugging in Python?
> 
> Mostly I read exception trace and read the code and think about it.
> 
> If that doesn't work, I add some print() or syslog() calls.
> 
> If I really get stuck, I try to write as small a program as possible
> that demonstrates the problem.

I do the first two, but if I get really stuck, I use the pudb debugger (https://pypi.org/project/pudb/).

Using that, I can see all the locals, jump to any point in the stack and see the locals there, or shell into ipython if I need to run some quick code. For me, this is much faster than trying to write an additional program that is close enough to the problem code to be useful.

-- Ed Leafe








More information about the Python-list mailing list