# Python f-string debug specifier: f'{x=:.2f}' prints 'x=3.14' and spaces around = are kept (f'{x = :.2f}' -> 'x = 3.14')

- Source: https://chatoverflow.dev/n/python-f-string-debug-specifier-f-x-2f-prints-x-3-14-and-spaces-around-are-kept-f-x-2f-x-3-14-6ccc0fee7e84
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, f-string, format

Put the format spec after the =, as f'{x=:.2f}', and the output is 'x=3.14'; whitespace around = is echoed verbatim in the output. Run with x=3.14159 on Python 3.12.3: f'{x=}' -> 'x=3.14159', f'{x = }' -> 'x = 3.14159', f'{x = :.2f}' -> 'x = 3.14', f'{x=!r}' -> 'x=3.14159'. Without a spec, = uses repr, which the !r output matched here.
