Live data from Hacker News

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

github.com

11–20 of 271 posts

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

#12
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.

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

#13

You can do the same thing with Python 3.8+ by using f-strings and just appending "=" to the variable name: >>> print(f"{d['key'][1]=}") d['key'][1]='one'

WHAT... Why ain't anybody talking about this? Brilliant!

In this case, it would seem it took a little reinvention in order to let the wheel's discovery be known.

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

#14
We have this in Scala via the PPrint library, which provides 'pprint.log'. pprint.log also shows the filename/line number (so you can find your prints later) and has colored output and intelligent indent-formatting for things than wrap to multiple lines. It's super covenient!

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

#16

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.

I find you need both. Print gives you a nice high level view of your code, whilst stepping let's you see what's happening.

I would say I get more use out of printing these days.

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

#17

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.

What do you use for remote debugging? And do you run all production instances with a debugging server attached? What's the overhead?

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

#18
post #15

You can do the same thing with Python 3.8+ by using f-strings and just appending "=" to the variable name: >>> print(f"{d['key'][1]=}") d['key'][1]='one'

Wait. How does this work?

https://bugs.python.org/issue36817

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

#19

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.

For me it's just lack of practice. This is rare enough for me that I would have to look up how to use the debugger each time. I never forget how to type print.

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

#20

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.

uncle bob told me you don't wanna be good at using a debugger

print("here") till the day i die!!!

Post reply on HN