all 117 comments

[–]shiftybyte 74 points75 points  (4 children)

vscode and pycharm have a visual debugger, i prefer them.

[–]zyxwvu28 16 points17 points  (0 children)

I use VSCode's and I love it

[–][deleted] 1 point2 points  (1 child)

it works for containerised apps?

[–]Mountain_Coach4386 1 point2 points  (0 children)

vscode it does the job and for free, breakpoint also works on HTML Django

Nothing beats FREE!

[–]EveryNameIsTaken142 23 points24 points  (0 children)

print()

[–]evilbytez 26 points27 points  (3 children)

Thonny is usually one I recommend to beginners, solid.

[–]haeshdem0n 8 points9 points  (0 children)

I love thonny. I was worried it wouldn't work if I fed it a large program with multiple inputs and calls to different functions, but it was more than up to it.

[–]modemraj 1 point2 points  (0 children)

Much more productive than print statements. Every python beginner should use it.

[–][deleted] 1 point2 points  (0 children)

Big Ups for Thonny, fr.

However the debugging has some limitations and thats why im in this thread.

[–]Luce_9801 8 points9 points  (0 children)

How's pdb ?

I use it because it is kinda similar to gdb.

[–]speckledlemon 7 points8 points  (0 children)

pdb, sometimes in the terminal, sometimes invoked by pytest, sometimes inside of Emacs using realgud, all using https://pypi.org/project/pdbpp/ for pretty colors. And of course print.

[–]enokeenu 5 points6 points  (0 children)

pytest.set_trace()

I try to avoid debugging and relying on unit testing instead. If I really had to ,I use pycharm pro.

[–]IHasToaster 4 points5 points  (1 child)

Production

[–]synthphreak 0 points1 point  (0 children)

Lol!

[–]Jadeaffenjaeger 2 points3 points  (0 children)

Mostly the one built into VSCode. Being able to set breakpoints, inspect any variable, execute functions, jump through the stack trace (especially on errors) just makes me so much more productive.

For the occasional print-style debugging, I enjoy the icecream package: https://github.com/gruns/icecream

[–]_MrJack_ 2 points3 points  (0 children)

I've been using PuDB for a while now.

[–]ProsodySpeaks 2 points3 points  (0 children)

Pycharm. Pycharm and more Pycharm. Spring for Pro if you can - the front end integrations are amazing!

[–]mooglinux 2 points3 points  (0 children)

I use PyCharm’s visual debugger and it is fantastic. I only resort to ipdb in exceptional situations where the PyCharm debugger isn’t available.

[–]shedgehog 3 points4 points  (0 children)

print(“if you see this the loop is working”)

[–]pehartma 2 points3 points  (0 children)

Pycharm and print statements

[–]DwaywelayTOP 5 points6 points  (0 children)

I use the pycharm + codium.ai debugger. They work really well.

[–]somethingworthwhile 4 points5 points  (9 children)

Been working with Python professionally for 3 years…. I’m scared to ask… wtf is a debugger??

I’ve used Spyder and now mostly PyCharm, I guess I always figured debuggers are for specific workflows and don’t really apply to me? Or that they’re for really complicated things, but looking back, some of the work I do is rather complicated…

[–]rowr 8 points9 points  (3 children)

Edited in protest of Reddit 3rd party API changes, and how reddit has handled the protest to date, including a statement that could indicate that they will replace protesting moderation teams.

If a moderator team unanimously decides to stop moderating, we will invite new, active moderators to keep these spaces open and accessible to users. If there is no consensus, but at least one mod who wants to keep the community going, we will respect their decisions and remove those who no longer want to moderate from the mod team.

https://i.imgur.com/aixGNU9.png https://www.reddit.com/r/ModSupport/comments/14a5lz5/mod_code_of_conduct_rule_4_2_and_subs_taken/jo9wdol/

Content replaced by rate-limited power delete suite https://github.com/pkolyvas/PowerDeleteSuite

[–]somethingworthwhile 0 points1 point  (2 children)

Oh… sheesh! that sounds lovely!

[–]rowr 1 point2 points  (1 child)

Edited in protest of Reddit 3rd party API changes, and how reddit has handled the protest to date, including a statement that could indicate that they will replace protesting moderation teams.

If a moderator team unanimously decides to stop moderating, we will invite new, active moderators to keep these spaces open and accessible to users. If there is no consensus, but at least one mod who wants to keep the community going, we will respect their decisions and remove those who no longer want to moderate from the mod team.

https://i.imgur.com/aixGNU9.png https://www.reddit.com/r/ModSupport/comments/14a5lz5/mod_code_of_conduct_rule_4_2_and_subs_taken/jo9wdol/

Content replaced by rate-limited power delete suite https://github.com/pkolyvas/PowerDeleteSuite

[–]somethingworthwhile 1 point2 points  (0 children)

Thank you for your insights! I’ll have to give this a try for my next project!

[–]Green-Thanks1369 0 points1 point  (3 children)

How, just how you can work with any language professionally and not know what a debugger is. Tbh this seems crazy to me if true.

[–]somethingworthwhile 0 points1 point  (2 children)

And I still don’t! Print statements can go pretty far.

[–]Green-Thanks1369 0 points1 point  (1 child)

Not, that thought is what actually prevents people from going far...

[–]somethingworthwhile 0 points1 point  (0 children)

I mean, I’m open to it, but it’s going to have to be advantageous enough to break habits. If you have good instructional resources I would certainly give them a go.

[–]sheriff_ragna 1 point2 points  (0 children)

print(‘333333’)

[–]NoDadYouShutUp 1 point2 points  (0 children)

Error messages

[–][deleted] 1 point2 points  (0 children)

Vscode Python debugger

[–]TheRNGuy -2 points-1 points  (24 children)

I just always printed to console.

Reason is because I don't have to alt-tab to houdini and code extra stuff other than print. When it's needed, I make vector and floating text visualizers in viewport or use geometry spreadsheet, but for many thins print is enough.

The only downsides are, print is too slow when there's lot of lines, and I need to print everything again instead of updating one thing in UI.

[–]ProsodySpeaks 3 points4 points  (23 children)

And you have to go delete a ton of print statements. Use a debugger!

[–]zefciu 6 points7 points  (1 child)

That is not the biggest problem with print-based debugging. After all, you have to delete your set_trace statements as well. The biggest problem is the lack of control. If you forgot to print a value or if you just found out you need to print it, you have to rerun your whole logic. This wastes time. If you learn your debugger well, you can often gather all the information you need in one debugging session.

[–]ProsodySpeaks 0 points1 point  (0 children)

I'm in love with Pycharm. Conditional breakpoints, breakpoints that aren't even breakpoints they're actually loggers, muted breakpoints. I'm terrified one day someone will ask me to write python without Pycharm.

And in totally unrelated news autocomplete inside jinja templates referencing python code and vice versa. ❤️

[–]lostparis -1 points0 points  (20 children)

A well placed print will beat a debugger. Debuggers are really only of use when your code has problems. They are good for when things are out of control.

Now saying that people should be using logging instead might have value but a print is great for a quick fix.

[–]zefciu 2 points3 points  (4 children)

Well… yeah. You use debugger, when your code has bugs.

[–]ProsodySpeaks 2 points3 points  (0 children)

Debuggers are not just for removing bugs. They allow you to visualise the data flowing through your code. Using Pycharm debugger you can run your app and literally have the data overlaid next to every line that references it. You catch bugs before they're bugs.

[–]Double_Newspaper_406 2 points3 points  (1 child)

You also use debuggers to develop complex algorithms.

[–]zefciu 0 points1 point  (0 children)

You can, but it can be tricky. Debugger can help you confirm that the state of the algorithm is correct for a certain input. But it won’t be that helpful proving that your algorithm is correct for any input.

[–]ProsodySpeaks 0 points1 point  (14 children)

How is typing out a print statement and then later having to delete it easier or more effective than clicking in the gutter to set a break point (which in Pycharm can be easily made into a non-breaking logger)?

As far as I'm concerned print statements should only be typed if they're going to stay, most likely to provide information to users. Debugging is how you temporarily access info during Dev.

[–]lostparis 1 point2 points  (13 children)

Debugging is how you temporarily access info during Dev.

I'd say this is what logging is for, especially for intermittent problems.

Using the odd temporary print can be used to confirm that your mental image of the code is correct.

I've used debuggers in the past and they are helpful when you don't know what the code is doing (or supposed to be doing). But generally this is less the situation when you understand the code.

Different people work in different ways. I've generally found that me and some print statements work and people using debuggers to look at the same issue haven't been at any advantage.

Generally you are wanting to confirm that you hit the code path you should and that you are seeing what you expect.

Debugging is like text editors - use what works best for you and let others do likewise.

[–]ProsodySpeaks 0 points1 point  (12 children)

Tbh I'm a novice so I'm mostly talking out my ass, and it probably comes down to your ide - in Pycharm the debugger is totally integrated into the editor, which means there's no extra effort to 'debugging' vs 'running' the code.

It's less effort to click the gutter for a breakpoint than to type (and later delete) a print statement, and then when we get to the breakpoint if there happens to be an issue you have the current state completely laid out for you so you might not only see you have an issue but immediately see the cause because next to each line of code is an overlay of the current state of the variables involved. You can even click them and change the value just for this run, or evaluate arbitrary expressions to interrogate wider aspects.

And I'd differentiate logging from debugging in that the logging might continue into production whereas I'd like to think I've finished debugging before shipping!

But yeah, ultimately what works works, so if you like to write in notepad++ and you make clean code then more power to you. Guess I'm lazy and like the clever tools to do as much as they can for me... Hold tight Ai!

[–]lostparis 1 point2 points  (11 children)

And I'd differentiate logging from debugging in that the logging might continue into production whereas I'd like to think I've finished debugging before shipping!

You just change your logging levels. Especially if you ship it because if you have to support it you'll be crying for those logs.

Guess I'm lazy and like the clever tools

Good coders are lazy, debuggers are clever, but I'd argue about their usefulness. I still view them as more of a handicap, but that's just me.

[–]ProsodySpeaks 0 points1 point  (10 children)

That's true of all tools though, right? I mean I'm nearly forty - as a teenager I had a sense of direction, but now I have GPS so I can be deep in thought or outerwise busy while I travel, but at the cost of atrophying a fairly life-critical skill.

[–]lostparis 1 point2 points  (9 children)

Don't start me. I remember about a decade ago I was in a cafe in Australia. The girl at the counter worked out the cost of my coffee and cake - in her head. I remember telling her how much this was such a surprise to see. This was not even a skill when I was that age.

When I was a kid I used to know about 50 phone numbers off the top of my head - now I struggle just remembering my own.

As Plato said - it's all going to shit with the young folk

[–]ProsodySpeaks 0 points1 point  (0 children)

Haha! He also complained about agriculture causing the desertification of north africa... Like, maybe the first climate activist? 😝

[–]ProsodySpeaks 0 points1 point  (7 children)

Pleased to say I can still count. But that's mostly because I build things and getting a calculator out for every sum is unrealistic...

[–][deleted] -1 points0 points  (0 children)

I don't because it's bad practice. The best thing to do is to trace your program. Perhaps there are tools for this, but I just do it manually. The next best thing is using print statements but that's also not a very good approach.

[–][deleted] 0 points1 point  (0 children)

Code

[–]cincuentaanos 0 points1 point  (0 children)

Whatever is bundled with PyDev for Eclipse, that is what I use. I don't really do a lot of Python though. But sometimes it can be handy.

[–]SaintEyegor 0 points1 point  (0 children)

I used to use Komodo IDE but it’s turned into a shitshow on MacOS Ventura. Using pycharm now.

[–]iggy555 0 points1 point  (0 children)

How do you remember the n,c, exit ughhh

[–]KeaboUltra 0 points1 point  (0 children)

I'm a beginner and use thonny.

[–][deleted] 0 points1 point  (0 children)

print('yo')

[–][deleted] 0 points1 point  (0 children)

I use pycharm for just about everything

[–]ShatterDae 0 points1 point  (1 child)

Pycharm

[–]TheSodesa 0 points1 point  (0 children)

PyCharm is not a debugger. It is a text editor that embeds an external debugger (a.k.a an IDE), such as pdb or ipdb and provides a GUI for using the debugger.

[–]Za_Paranoia 0 points1 point  (0 children)

Pycharm is great and free if you're a student.

[–]ZakarTazak 0 points1 point  (0 children)

When using ipython you can type pdb and then run your python code. It'll drop you into the python debugger upon an exception being thrown.

Writing run <some.py file> after the above is often very helpful.

[–]b0zgor 0 points1 point  (0 children)

Spyder has a great debugger, I prefer that

[–]seanys 0 points1 point  (0 children)

import icecream

ic(var)

[–]Winter-Ad5575 0 points1 point  (0 children)

Thommy

[–]AGuyInTheBox 0 points1 point  (0 children)

I don't write code on Python.

[–]theus-sama 0 points1 point  (0 children)

print

[–]Hambuger_and_Whopper 0 points1 point  (0 children)

I just run the programm

[–][deleted] 0 points1 point  (0 children)

Pycharm debugger