O
17

Tried Python's built-in debugger instead of print statements after 3 months of guessing bugs

I was always doing print("here") in loops to find where my code crashed, and it took me 2 hours to fix a simple list index error. Switched to pdb last week and caught the same problem in 10 minutes. Has anyone else been stubborn about using a debugger too long?
3 comments

Log in to join the discussion

Log In
3 Comments
lucaslee
lucaslee18d agoMost Upvoted
Nah, I gotta disagree with you guys. Print debugging has its place and it's not always the wrong tool. When I'm debugging something that runs in production where I can't set breakpoints, or a complex data pipeline where I need to see what values are flowing through multiple stages, a well-placed print statement gives me exactly what I need without messing with my workflow. pdb is great for stepping through logic but sometimes you just want a quick log of what's happening without freezing everything. I still use both depending on the situation.
10
park.abby
park.abby1mo ago
3 months is actually pretty fast compared to some people. I knew a guy who used print statements for almost two years before he finally gave pdb a real shot. He swore it was faster but he was lying to himself. Once you get used to setting breakpoints and stepping through code line by line, there's no going back. It's like the difference between using a hammer to open a can of paint versus just using the right tool from the start.
9
robert_anderson69
Yeah "he swore it was faster but he was lying to himself" pretty much sums it up. I did the same thing for about six months before I finally tried pdb. Now I just stick a breakpoint in, type "c" to skip to the crash, and check my variables right there instead of scrolling through 50 "here" prints. It's honestly embarrassing how long I spent being stubborn about it.
6