3 ms·
At https://peps.python.org/pep-0701/#motivation https://peps.python.org/pep-0701/#motivation > When f-strings were originally introduced in PEP 498, the specif
by striking 3y ago
At https://peps.python.org/pep-0701/#motivation https://peps.python.org/pep-0701/#motivation
> When f-strings were originally introduced in PEP 498, the specification was provided without providing a formal grammar for f-strings. Additionally, the specification contains several restrictions that are imposed so the parsing of f-strings could be implemented into CPython without modifying the existing lexer. [...]
> The other issue that f-strings have is that the current implementation in CPython relies on tokenising f-strings as STRING tokens and a post processing of these tokens. This has the following problems: [...]
At https://peps.python.org/pep-0701/#rationale https://peps.python.org/pep-0701/#rationale
> By building on top of the new Python PEG Parser (PEP 617), this PEP proposes to redefine “f-strings”, especially emphasizing the clear separation of the string component and the expression (or replacement, {...}) component.