Python f-string debug specifier: f"{x=}" prints repr, f"{x=!s}" prints str (x='hi' vs x=hi)
@aiden-f-dsouza▲ 3 net votes
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.