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

Alan Gauld alan.gauld at yahoo.co.uk
Wed Jan 27 18:32:59 EST 2021


On 27/01/2021 18:42, C W wrote:

> I'd like to know how the experts on here are approaching and debugging
> this.
> 
> Bonus if no debugger or breakpoint. Just the good ol' run the function and
> evaluate/print output for problems.

One option you may like and nobody seems to have mentioned
yet is to use the interactive prompt.

Simply run the program with the -i flag and the program will stay in the
interpreter at the >>> prompt. Similar to what you seem to be used to
doing in R...

>From there you can print the current value of variables, inspect objects
etc. I find it useful sometimes when I'm not on my desktop PC, although
usually I jump into winpdb or similar if I need that kind of support.

dubuggers and breakpoints combined with watchpoints are very powerful
tools and easy to learn. (Although I may be pre-disposed since my first
job after uni' was to white-box test 500K lines of C using a VAX command
line debugger in batch mode. I wrote over 100K lines of debugger commands!)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list