Icecream: Never use print() to debug again in Python
1–10 of 271 posts
Re: Icecream: Never use print() to debug again in Python
#2Re: Icecream: Never use print() to debug again in Python
#3print(f’{foo(123)=}’)
Which prints: foo(123)=‘result’
Re: Icecream: Never use print() to debug again in Python
#4Re: Icecream: Never use print() to debug again in Python
#5 >>> print(f"{d['key'][1]=}")
d['key'][1]='one'Re: Icecream: Never use print() to debug again in Python
#6Re: Icecream: Never use print() to debug again in Python
#7I am always going to use print to debug in every programming language I can until the day I die.
With a stepping debugger, I tend to get lost in the weeds. My suspicion is that the bug fixes I come up with are less holistic when using a debugger.
Re: Icecream: Never use print() to debug again in Python
#8All you need is `import q`. q works like a function (q(x)), like a variable (q|x and q/x, so you get different operator precedences) and like a decorator (@q), so it can be used in practically any circumstance for a quick debug print. Plus, the name sounds like you’re interrogating something.
Re: Icecream: Never use print() to debug again in Python
#9I 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
#10You 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'