Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions pep-0701.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -355,8 +369,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


Expand Down