You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Update the grammar for f-strings on "Lexical analysis" page #116580
The main use case for this is to link to the f-string grammar. It's difficult to do so on the "Full Grammar specification" page but it's easy on an individual section.
The full grammar specification is generated from the grammar file itself (although stripped down quite a bit).In the lexical analysis page, there's grammars for many different syntactic constructs of the language that are directed to humans and are written in a way that should reflect that. They're also all consistent in the syntax they use, so changing only one place and have it written in PEG feels a bit odd.
If all you care about is being able to link to the f-string grammar for other people to read, then that grammar in the lexical analysis page is certainly good enough and covers what the real PEG grammar should be able to cover as well. If you want to link to the real grammar that's used at runtime, linking to https://github.com/python/cpython/blob/main/Grammar/python.gram#L912-L927 is probably good enough?
Yeah, I'm giving a bit of time each week to generating docs from the actual grammar, and hope to do it by 3.13. But i want to look at f-strings (and other topics that need touch lexical docs) last.
It should be good enough although I would still prefer have it link to the language reference to include any contextual information as well.
@encukou Thank you! If there's a tracking issue for the same, we can merge this into it otherwise I leave it at your discretion to keep this open or not. I'm fine closing it.
No issue yet, just discussion.
I'll assign this to myself: it might be a few months before I get to this, but do talk to me if you want to start working on it earlier :)
Activity
terryjreedy commentedon Mar 11, 2024
@pablogsal
lysnikolaou commentedon Mar 11, 2024
I'm not sure whether this is the way to go.
The full grammar specification is generated from the grammar file itself (although stripped down quite a bit).In the lexical analysis page, there's grammars for many different syntactic constructs of the language that are directed to humans and are written in a way that should reflect that. They're also all consistent in the syntax they use, so changing only one place and have it written in PEG feels a bit odd.
If all you care about is being able to link to the f-string grammar for other people to read, then that grammar in the lexical analysis page is certainly good enough and covers what the real PEG grammar should be able to cover as well. If you want to link to the real grammar that's used at runtime, linking to https://github.com/python/cpython/blob/main/Grammar/python.gram#L912-L927 is probably good enough?
hugovk commentedon Mar 12, 2024
Also cc @encukou who was been working on grammar docs.
encukou commentedon Mar 12, 2024
Yeah, I'm giving a bit of time each week to generating docs from the actual grammar, and hope to do it by 3.13. But i want to look at f-strings (and other topics that need touch lexical docs) last.
dhruvmanila commentedon Mar 12, 2024
Yeah, I agree. I wasn't aware of that.
It should be good enough although I would still prefer have it link to the language reference to include any contextual information as well.
@encukou Thank you! If there's a tracking issue for the same, we can merge this into it otherwise I leave it at your discretion to keep this open or not. I'm fine closing it.
encukou commentedon Mar 12, 2024
No issue yet, just discussion.
I'll assign this to myself: it might be a few months before I get to this, but do talk to me if you want to start working on it earlier :)
encukou commentedon Sep 5, 2025
See #137469