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

Chris Green cl at isbd.net
Wed Jan 27 04:12:43 EST 2021


Skip Montanaro <skip.montanaro at gmail.com> wrote:
> CW> How do you troubleshooting/debugging in Python?
> 
> GE> Mostly I read exception trace and read the code and think about it.
> GE> If that doesn't work, I add some print() or syslog() calls.
> 
> CW> I know hardcore computer scientists would tell me about Python debugger.
> 
> GE> I've been writing Python for 20+ years. I've never tried a debugger.
> 
> Agree with Grant on these points. I certainly use gdb to debug C code
> (like the interpreter), but for Python code, tracebacks and print
> statements pretty much take care of things. I know pdb has been around
> for a long while and many people like IDEs, but I've not generally
> found them all that useful. I'm stuck in the 90s I guess.
> 
Me too! :-)

I tend to use multiple terminal windows so I have the code being
edited in one window, run the code in another window and sometimes a
third window for looking at configuration etc.

Add print statement etc. for debugging.

-- 
Chris Green
·


More information about the Python-list mailing list