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

2QdxY4RzWzUUiLuE at potatochowder.com 2QdxY4RzWzUUiLuE at potatochowder.com
Wed Jan 27 18:04:12 EST 2021


On 2021-01-27 at 17:41:52 -0500,
C W <tmrsg11 at gmail.com> wrote:

> Great tutorial Irv, very simple with if-else example, gets the point
> across.

Disclaimer:  I did not watch the video.

> My main takeaway from the discussion so far is that: you can't
> troubleshoot Python without some kind of breakpoint or debugger.

I disagree.  :-)

Having spent a long time developing and debugging embedded systems (some
soft- or hard- real time), I believe that you can troubleshoot programs
(regardless of source language) without debuggers.  If a system can
generate output, then I (the programmer) can change that output, observe
the results, and figure out what's working and what's not.  Yes, some
systems are more painful than others, but yes, some debugging
environments are more painful than others, too.

A well placed call to print (they're not "print statements" anymore!)
can be much more enlightening and much faster than single stepping
through code in a debugger, and seeing the output from the same print
statement inside a loop can be much better than manually examining
variables iteration after iteration and trying to remember what the
value was before.

The best debugging tool, however, remains your brain.  Way before I add
a call to print or you set up your debugger, thinking about what went
wrong and where to look can solve the problems without resorting to
external tools.  :-)


More information about the Python-list mailing list