TIL - Python f-string expression value


There’s a python module called icecream which provides a nice ic() function to print an expression and its value, but in a discussion about it I learned that a quick equivalent can be achieved by using Python f-strings (available since Python 3.6) and appending “=” to the variable name:

>>> print(f"{d['key'][1]=}")
d['key'][1]='one'