#trick

❇️ Do you print Python variables like this:
>>> print(f'x = {x}')

❇️ You're working too hard! As of Python 3.8, you can say:
>>> print(f'{x = }')

It shows the variable name, =, then the value. Actually, all expressions work:

>>> print(f'{len("abc") = }')
len("abc") = 3

Comments

Be the first to add a comment