Of course then you can't brag to your friends about using Vim or Emacs ;)
Icecream: Never use print() to debug again in Python
101–110 of 271 posts
Re: Icecream: Never use print() to debug again in Python
#102Earlier quoted context omitted.
Not necessarily. I know very well how to use a debugger, but nowadays I just prefer to use prints: it forces to you actually think about what's happening instead of just looking at it. It's also more useful in situations where putting a debugger actually changes behavior (high performance systems, parallel programs).
I would expect print-debugging to change the behavior in such cases too. Usually writing to stdout is behind some synchronization so using print debugging will drop performance and make program less parallel.
Re: Icecream: Never use print() to debug again in Python
#103You 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'
You can also make it a bit prettier by adding spaces: >>> print(f"{d['key'][1] = }") d['key'][1] = 'one' It works with any expression you like, not just variables: >>> print(f'{np.sin(np.pi/4.) = }') np.sin(np.pi/4.) = 0.7071067811865475
Also assignment expressions? :)
Re: Icecream: Never use print() to debug again in Python
#104Re: Icecream: Never use print() to debug again in Python
#105Why 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.
> Why don't people just use a debugger? I only speak for myself, but I find that time spent inside a debugger is "lost", and bound to be re-spent again and again if you ever find new problems with the same code. I pretty much prefer to add assertions, logging and comments to my program, that will stay there and make further re-reads easier and more useful. As a matter of principle, I never use a debugger (except for…
Re: Icecream: Never use print() to debug again in Python
#106Earlier quoted context omitted.
You can also make it a bit prettier by adding spaces: >>> print(f"{d['key'][1] = }") d['key'][1] = 'one' It works with any expression you like, not just variables: >>> print(f'{np.sin(np.pi/4.) = }') np.sin(np.pi/4.) = 0.7071067811865475
> It works with any expression you like Also assignment expressions? :)
>>> print(f"{(yes:='yes')=}")
(yes:='yes')='yes'Re: Icecream: Never use print() to debug again in Python
#107I am sorry, but I am not going to pull in an external dependency just for this, especially not with the power of fstrings in newer python versions.
You're just being difficult. It's easy, you just setup these 10 Node.js micro services in docker, setup your database, the cache. Then my friend, you can really debug with beautiful print messages. Wait until someone creates a $10/user SaaS service out of it.
Re: Icecream: Never use print() to debug again in Python
#108I am always going to use print to debug in every programming language I can until the day I die.
Re: Icecream: Never use print() to debug again in Python
#109Re: Icecream: Never use print() to debug again in Python
#110This looks cool and all, but why is it called Icecream? I know naming abstract stuff is hard but it feels like this lends itself to a more descriptive name. "ic()" tells me nothing about what the function does.
When read phonetically as letter names, the name "ic" sounds like "I see".
"ic" also is an initialism for "ice cream".
Everyone loves ice cream, and so another low-meaning cutesy-poo pun-ishment of a name was born.
I think. Pure speculation here.