]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-81039: Add small example of f-string's "=}" to tutorial (gh-92291)
authorStanley <46876382+slateny@users.noreply.github.com>
Wed, 21 Sep 2022 12:57:03 +0000 (05:57 -0700)
committerGitHub <noreply@github.com>
Wed, 21 Sep 2022 12:57:03 +0000 (08:57 -0400)
Doc/tutorial/inputoutput.rst
Doc/whatsnew/3.8.rst

index d3414005a534352a5d87b554d827e05a5a4b74b9..de84ab7fac8faa41f0e48b3eff00454c683a55fd 100644 (file)
@@ -133,7 +133,17 @@ applies :func:`repr`::
    >>> print(f'My hovercraft is full of {animals!r}.')
    My hovercraft is full of 'eels'.
 
-For a reference on these format specifications, see
+The ``=`` specifier can be used to expand an expression to the text of the
+expression, an equal sign, then the representation of the evaluated expression:
+
+   >>> bugs = 'roaches'
+   >>> count = 13
+   >>> area = 'living room'
+   >>> print(f'Debugging {bugs=} {count=} {area=}')
+   Debugging bugs='roaches' count=13 area='living room'
+
+See :ref:`self-documenting expressions <bpo-36817-whatsnew>` for more information
+on the ``=`` specifier. For a reference on these format specifications, see
 the reference guide for the :ref:`formatspec`.
 
 .. _tut-string-format:
index 077de05f34c93e288f6a980baa5b5a8292d0133b..a85a12604ea4c10f16a6c98b1c9b6c2208cf46b4 100644 (file)
@@ -250,6 +250,7 @@ Android and Cygwin, whose cases are handled by the script);
 this change is backward incompatible on purpose.
 (Contributed by Victor Stinner in :issue:`36721`.)
 
+.. _bpo-36817-whatsnew:
 
 f-strings support ``=`` for self-documenting expressions and debugging
 ----------------------------------------------------------------------