← All notes

Write a formalized f-string after PEP 701

Answer: A formatted string literal, also called an f-string, is prefixed with f or F. Those literals do not have a constant value. They may contain replacement fields delimited by curly braces {}. PEP 701 lifts some of the restrictions originally formulated in PEP 498.

Replacement fields

Replacement fields contain expressions which are evaluated at runtime. PEP 701 provides a formalized grammar for f-strings that can be integrated into the parser directly.

Side effects of the formalization

The formalization will have some small side-effects on how f-strings are parsed.

| f-string | PEP 701 | |---|---| | f or F | Prefix on a formatted string literal | | replacement fields | Delimited by curly braces | | PEP 498 | Original restrictions that PEP 701 lifts | | parser | Where the formalized grammar is integrated |

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 701 – Syntactic formalization of f-strings; Python docs, Lexical analysis. Public-Domain; PSF-2.0. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 701 – Syntactic formalization of f-strings; Python docs, Lexical analysis. Public-Domain; PSF-2.0.

Cite this

Permanent ID: iil:note:sdz9yqz7

iinventedlight. 2026. "Write a formalized f-string after PEP 701." iinventedlight Library, iil:note:sdz9yqz7, version of 2026-11-19. https://iinventedlight.com/library/notes/pep-701-fstring/. License: CC-BY-4.0.

@misc{iil_note_sdz9yqz7,
  author = {{iinventedlight}},
  title = {{Write a formalized f-string after PEP 701}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-19},
  url = {https://iinventedlight.com/library/notes/pep-701-fstring/},
  note = {Permanent ID iil:note:sdz9yqz7. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/pep-701-fstring.md.