Skip to content

f-string docs update: the level of expression nesting in format specifiers #124608

@YouJiacheng

Description

@YouJiacheng

PEP 701 said:

Similarly, this PEP leaves up to the implementation the level of expression nesting in format specifiers but specifies a lower bound of 2 levels of nesting. This means that the following should always be valid:
f"{'':*^{1:{1}}}"

However, the docs haven't updated:
image
image

BTW, IIUC the specification of f-string has moved from syntax(lexical) to grammar.
Thus, it probably should be moved from https://docs.python.org/3.12/reference/lexical_analysis.html#formatted-string-literals to https://docs.python.org/3.12/reference/grammar.html or https://docs.python.org/3.12/reference/expressions.html#literals. Or a special note should be added.
At least this lexical grammar is outdated and should be removed (or replaced by the PEG grammar):
image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions