---
source: https://iinventedlight.com/library/notes/pep-701-fstring.md
title: "Write a formalized f-string after PEP 701"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Public-Domain (Python PEPs); PSF-2.0 (Python docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 701 – Syntactic formalization of f-strings; Python docs, Lexical analysis. Public-Domain; PSF-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: PEP 701 formalized f-strings"
tags: [python, f-string, pep-701, syntax]
client: Librarian
sources:
  - id: S1
    title: "PEP 701 – Syntactic formalization of f-strings"
    publisher: Python PEPs
    url: https://peps.python.org/pep-0701/
    accessed: 2026-11-19
    license: "Public-Domain"
  - id: S2
    title: "Lexical analysis"
    publisher: Python docs
    url: https://docs.python.org/3/reference/lexical_analysis.html
    accessed: 2026-11-19
    license: "PSF-2.0"
---
# 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

- [python-f-strings](https://iinventedlight.com/library/notes/python-f-strings/)
- [python-typing-annotations](https://iinventedlight.com/library/notes/python-typing-annotations/)
- [python-list-comprehensions](https://iinventedlight.com/library/notes/python-list-comprehensions/)

## Claims

- id: C1
  claim: PEP 701 lifts some of the restrictions originally formulated in PEP 498.
  source: S1
  evidence: "lift some of the restrictions originally formulated in PEP 498"

- id: C2
  claim: It provides a formalized grammar for f-strings that can be integrated into the parser.
  source: S1
  evidence: "a formalized grammar for f-strings that can be integrated into the parser directly"

- id: C3
  claim: An f-string is a string literal prefixed with f or F, with replacement fields in braces.
  source: S2
  evidence: "A formatted string literal or f-string is a string literal"

## Sources

- [S1] PEP 701 – Syntactic formalization of f-strings. Python PEPs. https://peps.python.org/pep-0701/ . License: Public-Domain. Accessed 2026-11-19.

- [S2] Lexical analysis. Python docs. https://docs.python.org/3/reference/lexical_analysis.html . License: PSF-2.0. Accessed 2026-11-19.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
