f-string Debug Specifier And Conversions
The = specifier prints each expression beside its repr for self-documenting debug output, and the !r !s !a conversions pick the shape before formatting.
Code
ratio = 0.85
name = "café"
count = 3
# {expr=} is self-documenting debugging: expression text, equals sign, and repr in one print
print(f"{ratio=}")
print(f"{count * 2=}")
print(f"{list(range(3))=}")
# the !r/!s/!a conversions choose the pre-formatting shape: repr keeps quotes, ascii escapes non-ASCII
print(f"repr: {name!r} | str: {name!s} | ascii: {name!a}")
# the = specifier composes with format specs: equals sign first, precision after
print(f"{ratio=:.2f}")
print(f"{count=:03d}")Inside the snippet
Module-level bindings hold the data — ratio, name, count — with no function scope in between.
Where you would put it to use
The demo output is labeled (repr:), so every printed line maps back to its originating operation.
Interactive Tools for This Topic
DOM Event Propagation VisualizerVisualize DOM event capturing, targeting, and bubbling phases in real time. Toggle stopPropagation and stopImmediatePropagation to see how events traverse the tree.HAR Waterfall AnalyzerInspect HTTP Archive (HAR 1.2) JSON files locally to summarize total requests, status codes, MIME types, slowest calls, and timing waterfalls.Hex Dump ViewerPreview any text as a classic hexadecimal dump with byte offsets, sixteen bytes per row, and an ASCII column for quick inspection.HTTP Header AnalyzerPaste raw HTTP header lines and get a parsed name-value list with plain-language notes for common headers and security observations.
FAQ
- Is a package install part of the setup?
- No. Installation is unnecessary because only built-in APIs are used. Its state lives in module-level bindings: `ratio`, `name`, `count`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.