3 ms·
Although I find breakpoints to be helpful in some simple cases, for complicated work I prefer the print() approach because I can do complicated calculations bef
by bluenose69 4y ago
Although I find breakpoints to be helpful in some simple cases, for complicated work I prefer the print() approach because I can do complicated calculations before deciding whether to print (and what to print).
Plus, saving the information in a file is very handy, because it lets me examine state in some detail, with split editor windows, grep commands, etc. Quite often I'll preface the print() output with special tags that I can use to sift through the log in an editor or, in more complicated cases, with code that analyses the condition numerically or graphically.
I've been doing this for several decades. It ain't fancy, but it works. Compared with debugger actions like breakpoints, this helps me solve my problems much more quickly, and with greater insight.
Reframing Graham's statement at an individual level, print() is what I use, the vast majority of the time.
- dan-robertson 4y agoYou can also just use conditional breakpoints or add code to do some test and then call some dummy function on which you set a breakpoint. I don’t want to suggest that tracing or whatever the system you describe isn’t useful, but I think the main advantage people get from a debugger is being able to look at the values of things and step through the program execution (and often find that it does some surprising things).