News for hackers. Stuff that matters.
Re:The unreasonable effectiveness of print debugging by 1337shadow on Saturday April 24, 2021 @12:16PM (#26926023)
What Python debuggers you are talking about? have you tried the built-in CLI debugger? Just drop breakpoint() in your code and you're in. Have been using it daily for over a decade and really happy with it - it's actually one of my favorite features of the language, amongst the many super useful features that Python and its excellent stdlib have to offer.
Re:The unreasonable effectiveness of print debugging by CJefferson on Saturday April 24, 2021 @12:33PM (#26926165)
Honestly, I didn't know that and I'll try it. Last time I had to debug I remember adding "-m pdb" (as at the start of https://docs.python.org/3/library/pdb.html , first result in Google), but for some reason that immediately threw an error instead of starting the program, so I just chucked some prints in instead.
Re:The unreasonable effectiveness of print debugging by montecarl on Saturday April 24, 2021 @12:42PM (#26926230)
I have mapped a key to insert "import pdb;pdb.set_trace()" in my editor. Also use it daily, and not just for debugging. It is useful when working on a new project and you just want to interrogate some object you got back from a library to see what valid operations you can do with it. Or to double check some math operations.
Re:The unreasonable effectiveness of print debugging by 1337shadow on Saturday April 24, 2021 @12:55PM (#26926353)
I just tried python -m pdb and it works for me https://dpaste.org/9EQo#L26 but I really always use breakpoint(). You can even configure it to use other debuggers with an environment variable, ie.: PYTHONBREAKPOINT=ipdb.set_trace
Re:The unreasonable effectiveness of print debugging by CJefferson on Saturday April 24, 2021 @12:59PM (#26926393)
I just quickly went any checked the program I was trying to debug. I was running 'python3 package --arguments', where 'package' is the name of a directory which contains a package I was working on. 'python -m pdb package --arguments' just complains that 'package' is a directory.

Adding a 'breakpoint()' at the start of the program does get me into the debugger. I'll remember that for future (but, it's not easy to find by googling if you don't already know what you are looking for!)

Re:The unreasonable effectiveness of print debugging by fake-name on Saturday April 24, 2021 @10:10PM (#26929794)
For complex problems, `import pdb; pdb.set_trace()` instead of a print statement can be super handy. It basically launches the debugger from the context of wherever you stuck the line.

For large unwieldy data-structures, you can go ipython: `import IPython; IPython.embed()` launches the ipython REPL from the calling line's context.

I use the latter a fair bit when spelunking around in other people's code. `pdb.set_trace()` lets you continue execution more easily.

Re:The unreasonable effectiveness of print debugging by kbd on Saturday April 24, 2021 @01:15PM (#26926551)
Never felt that Python debugging was "fragile". BTW if you're not using pudb you're missing out.
Re:The unreasonable effectiveness of print debugging by zmmmmm on Saturday April 24, 2021 @05:41PM (#26928427)
Only thing I hate about this .... regular point of code review: remove the debugger breakpoint you left in your code!

We haven't had one hit production yet, but it came close. Print statement is a lot more harmless.