Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Stop Writing print('var =', var) in Python
May 29, 2026
We've all been there: quickly sprinkling print statements throughout our code to see what a variable holds during runtime. But writing 'print(f"user_id: {user_id}")' over and over gets tedious. Next time, try the f-string shortcut by adding an equals sign after the variable name: 'print(f"{user_id=}")'.
This will automatically output both the variable name and its value (for example, 'user_id=42'), saving you keystrokes and making your quick-and-dirty debugging sessions much faster. It even works with expressions, like 'print(f"{len(users)=}")'!