PEP 701 – Syntactic formalization of f-strings

Both of these are valid with our current implementation:

>>> x = 1
>>> f"___{
...     x
... }___"
'___1___'
>>> f"___{(
...     x
... )}___"
'___1___'

It also handles debug expressions:

>>> f"___{
... 1
... +
... 1
... =}___"
'___\n1\n+\n1\n=2___'
>>> print(_)
___
1
+
1
=2___
1 Like