Python Principles
Python Q&A

F-strings: what does an equals sign do?


Equals signs are now allowed inside f-strings starting with Python 3.8. This lets you quickly evaluate an expression while outputting the expression that was evaluated. It's very handy for debugging. For example:

x = 3
print(f'{x*9 + 15=}')

When evaluated, this prints:

x*9 + 15=42

By using something like print(f'{myvar=}'), you can save time during debugging.