Live data from Hacker News

Icecream: Never use print() to debug again in Python

github.com

41–50 of 271 posts

Re: Icecream: Never use print() to debug again in Python

#41
post #37
post #32

Earlier quoted context omitted.

It's strange, when developing C# and the like I'd go crazy without a debugger... and yet, in Python I've hardly ever used one. That might be because it's hard to develop C# without already being in an environment that puts an emphasis on easy debugging (Visual Studio), whereas I'm developing Python in whatever text editor I happen to be using at the moment and never really bothered to try out anything other than the…

Writing Python (and most other languages) with a proper IDE with integrated debugger and all is like eating right and exercising: it's much better when you do it, you feel better while doing it, each time you start again you think "why did I ever give this up?", and yet it takes conscious effort to keep it up, circumstances just make it so tempting to fall off the train. 'Oh just checking the value of that constant,…

I really agree with this. I would love to be in a clean self-built environment in vim or sublime or the likes, but IDE's just work and boost productivity.

Re: Icecream: Never use print() to debug again in Python

#44

Earlier quoted context omitted.

Actually rust has the functionality of Icecream as a buildin command "dgb" and you quickly find yourself using it over print

No doubt blatantly ripped off the venerable print_r :P

Nope, because unlike print_r dbg! returns the input as-is, so you should be able to wrap any expression in dbg! in-place, and just get debug output.

According to the RFC, the direct inspiration for dbg! is Haskell's traceShowId (http://hackage.haskell.org/package/base-4.10.1.0/docs/Debug-...).

Re: Icecream: Never use print() to debug again in Python

#47

I am always going to use print to debug in every programming language I can until the day I die.

Why not taking the (short) time to learn using a debugger? This is way more efficient way to work for complex situations.

I have debugger set in pycharm and use it all the time. I also use print all the time, often along with the debug tool. They are very complimentary and neither tool can do everything the other can.

Re: Icecream: Never use print() to debug again in Python

#48

I am always going to use print to debug in every programming language I can until the day I die.

Why not taking the (short) time to learn using a debugger? This is way more efficient way to work for complex situations.

> This is way more efficient way to work for complex situations.

It's also way more inconvenient for simple situations or when trying to sift through in order to zero-in on the issue's rough location, spatial or temporal: unless the debugger is well integrated into the editor it requires syncing multiple sources of information (the debugger's breakpoints configuration and the actual source) — and resynchronising on every edit; and if the debugger is well integrated into the editor… now I'm locked into a specific editor.

Re: Icecream: Never use print() to debug again in Python

#49

Earlier quoted context omitted.

Why not taking the (short) time to learn using a debugger? This is way more efficient way to work for complex situations.

I have debugger set in pycharm and use it all the time. I also use print all the time, often along with the debug tool. They are very complimentary and neither tool can do everything the other can.

TBF if you always run your programs in pycharm and use its debugger, you can trivially use non-suspending "evaluate and log" breakpoints instead of print.

Re: Icecream: Never use print() to debug again in Python

#50

Why don't people just use a debugger? It boggles my mind that people live with print style debugging. Depending on the project, it can be such a timer waster and just plainly worse in all aspects. Especially in Pycharm for me, it is incredibly easy. Even when running over ssh in remote computers I can use my debugger.

Right?? I find it really sad that python being the go-to "beginner/mess-around" language has such poor debugging in most environments. I've tried VSCode, Atom, Juno, Spyder, Jupyter(lab) and Thonny. All of them were either broken, buggy or cumbersome to step-debug in while also using the REPL. I will give PyCharm a go though.

The worst part is, I think a lot of devs resort to print-debugging which in turn leads to writing sloppy code - e.g. avoiding function calls to be able to access state, etc.

Post reply on HN