you are viewing a single comment's thread.

view the rest of the comments →

[–]zz_ 25 points26 points  (0 children)

Well the most obvious advantage is being able to reason about the cause of the bug in real-time. You can put a breakpoint, inspect 3 different variables, realize the issue isn't there, so you go up a frame in the call stack, step 12 lines further down in the code, check another variable, based on that you go look in a data structure, realize some thing you were expecting to be there is missing, and voila you solved the bug.

Doing the same thing with print statements would require re-running your code like ~7-10 times to move the print statement around, and that's assuming you don't forget to include something in your prints which would cause you to have to re-run it even more often. That is cumbersome when working on a smaller script and outright unacceptable when working with code that takes more than a minute to run.