f-string docs update: the level of expression nesting in format specifiers
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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:
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):
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing PEP 701 with the formatted string literals section at docs.python.org/3.12/reference/lexical_analysis.html and the referenced grammar and expressions sections. Update the documentation to describe the supported expression-nesting level and resolve whether the outdated lexical grammar should be removed, replaced, or accompanied by a note.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100