[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Eric V. Smith
On 9/21/2021 7:15 PM, Guido van Rossum wrote: On Tue, Sep 21, 2021 at 4:08 PM Steve Dower > wrote: On 9/21/2021 7:42 PM, Eric V. Smith wrote: > I don't recall exactly why, but I disallowed backslashes inside > expressions at the last minute before 3.6 w

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Guido van Rossum
On Tue, Sep 21, 2021 at 4:08 PM Steve Dower wrote: > On 9/21/2021 7:42 PM, Eric V. Smith wrote: > > I don't recall exactly why, but I disallowed backslashes inside > > expressions at the last minute before 3.6 was released. It might have > > been because I was interpreting them in a way that didn

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Steve Dower
On 9/21/2021 7:42 PM, Eric V. Smith wrote: I don't recall exactly why, but I disallowed backslashes inside expressions at the last minute before 3.6 was released. It might have been because I was interpreting them in a way that didn't make sense if a "real" parser were inspecting f-strings. The

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Barry Warsaw
On Sep 21, 2021, at 15:03, Terry Reedy wrote: > > If same-quote nesting were limited to 1 deep, REs could handle it. Since > nesting is not, and same-quote nesting would not be, they cannot in general. > > f'''length is {len(3*f"{f'{a}'}")}''' I tried this in the latest python-mode.el for Emac

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Terry Reedy
On 9/21/2021 3:29 PM, Guido van Rossum wrote: On Tue, Sep 21, 2021 at 11:49 AM Eric V. Smith > wrote: [Pablo] * The parser will allow nesting quote characters. This means that we **could** allow reusing the same quote type in nested expressions like th

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Guido van Rossum
On Tue, Sep 21, 2021 at 11:49 AM Eric V. Smith wrote: > [Pablo] > > * The parser will allow nesting quote characters. This means that we > **could** allow reusing the same quote type in nested expressions > like this: > > f"some text { my_dict["string1"] } more text" > > I'm okay with this, with

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Eric V. Smith
To bring this back on track, I'll try and answer the questions from your original email. On 9/20/2021 7:18 AM, Pablo Galindo Salgado wrote: I have started a project to move the parsing off-strings to the parser and the grammar. Appart from some maintenance improvements (we can drop a considerab

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Patrick Reader
I didn't meant to bring back backticks, but to use the semantics they have in shell languages of using backslashes to escape nested substitutions, like this: f"string {code f\"string2 \{code2\} string2\" code} string" Upon reflection though, I agree that since we already use brackets which lend

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Pablo Galindo Salgado
>> What do you envision tokenize.py will do with f-strings after this? It will emit new tokens: FSTRING_START FSTRING_MIDDLE '{' NAME FSTRING_FORMAT '}' FSTRING_END On Tue, 21 Sept 2021 at 12:50, Anders Munch wrote: > Pablo Galindo Salgado [mailto:pablog...@gmail.com] wrote: > > We already ex

[Python-Dev] Re: f-strings in the grammar

2021-09-21 Thread Anders Munch
Pablo Galindo Salgado [mailto:pablog...@gmail.com] wrote: > We already expose APIs that return AST objects that can be used for all sort > of things and a tokenizer module that exposes some form of lexing that is > relatively close to the one that CPython uses internally. What do you envision