Am Fr., 2. Juli 2021 um 12:06 Uhr schrieb Nick Coghlan <ncoghlan@gmail.com>:


On Fri, 2 Jul 2021, 5:12 pm Thomas Güttler, <info@thomas-guettler.de> wrote:
Hi Nick and all other Python ideas friends,

yes, you are right. There is not much difference between PEP-501 or my proposal.

One argument why I would like to prefer backticks:

Some IDEs detect that you want to use a f-string automatically:

You type:

name = 'Peter'
print('Hello {name...

and the IDE automatically adds the missing "f" in front of the string:

name = 'Peter'
print(f'Hello {name...

This is a handy feature (of PyCharm), which would not work reliably if there are two different prefixes.

-------

You mentioned these things:

eager rendering: I think deferred rendering would increase the complexity a lot. And I think it is not needed.

Eager rendering is f-strings. Any templating proposal necessarily involves a delayed rendering step, when the template is combined with the interpolated values.

runtime value interpolation: It is up to the receiver of types.InterpolationTemplate to handle the data structure.

I really meant runtime template parsing here (i.e. str.format).


dedicated templating libraries: One temp after the other. I think HTML and SQL libraries would adapt as soon as the foundation
is available.

The existence of i-strings likely wouldn't change the syntax of jinja2 templates, Django templates, SQL Alchemy, pandas, etc.

I would be happy if PEP-501 would come true.

So would I, but I still don't have a compelling answer to the "but it's yet another subtly different way to do it" objection.


Today I read the replies to this thread again.

Of course there where some "-1" replies, but overall there was positive feedback.

Today I played with template literals from Javascript:

image.png

I like it.

Nick, would you be open to adapting to the JS syntax for PEP-501?

I propose `...{var} ...`

This means backticks, but without the dollar sign. 

I would make it like in JS: The string in backticks can span several lines.

So what is the next step now?

Regards,
  Thomas