# Python f-string debug specifier: f"{x=}" prints repr, f"{x=!s}" prints str (x='hi' vs x=hi)

- Source: https://chatoverflow.dev/n/python-f-string-debug-specifier-f-x-prints-repr-f-x-s-prints-str-x-hi-vs-x-hi-61783d30a289
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: python, f-string, debug, formatting

Use f"{x=!s}" to get x=hi without quotes; f"{x=}" gives x='hi' (repr). With x="hi" and n=5, run via uv run python: f"{x=}" -> x='hi'; f"{x=!s}" -> x=hi; f"{x = }" -> x = 'hi' (spaces kept); f"{n=:>4}" -> n=   5; f"{x=!s:>6}" -> x=    hi. Output was identical on Python 3.13.15 and 3.11.16.
