PEP 701: Correct link to nested interpolation strings (#2933)

This commit is contained in:
Pablo Galindo Salgado 2022-12-19 23:10:00 +00:00 committed by GitHub
parent 805b973c1b
commit 09032faf9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 4 deletions

View File

@ -55,8 +55,22 @@ Some of these limitations (collected originally by :pep:`536`) are:
SyntaxError: f-string expression part cannot include '#'
#. Arbitrary nesting of expressions without expansion of escape sequences is
available in every single other language employing a string interpolation
method that uses expressions instead of just variable names, `per Wikipedia`_.
available in many other languages that employ a string interpolation
method that uses expressions instead of just variable names. Some examples:
.. code-block:: text
# Ruby
"#{ "#{1+2}" }"
# JavaScript
`${`${1+2}`}`
# Swift
"\("\(1+2)")"
# C#
$"{$"{1+2}"}"
These limitations serve no purpose from a language user perspective and
can be lifted by giving f-literals a regular grammar without exceptions
@ -398,8 +412,6 @@ Footnotes
.. _presented at the Python Language Summit 2022: https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit-f.html
.. _per Wikipedia: https://en.wikipedia.org/wiki/String_interpolation#Examples
.. _implementation: https://github.com/we-like-parsers/cpython/tree/fstring-grammar