[Python-checkins] gh-81039: Add small example of f-string's "=}" to tutorial (gh-92291) (gh-96989)

ericvsmith webhook-mailer at python.org
Wed Sep 21 09:12:18 EDT 2022


https://github.com/python/cpython/commit/ad49555d5185fd2ec27a9c9ddc2b11b4f85c5b62
commit: ad49555d5185fd2ec27a9c9ddc2b11b4f85c5b62
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ericvsmith <ericvsmith at users.noreply.github.com>
date: 2022-09-21T09:11:48-04:00
summary:

gh-81039: Add small example of f-string's "=}" to tutorial (gh-92291) (gh-96989)

(cherry picked from commit 4b81139aac3fa11779f6eedb6e621bde29e64b30)

Co-authored-by: Stanley <46876382+slateny at users.noreply.github.com>

Co-authored-by: Stanley <46876382+slateny at users.noreply.github.com>

files:
M Doc/tutorial/inputoutput.rst
M Doc/whatsnew/3.8.rst

diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index d3414005a534..de84ab7fac8f 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -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:
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 51e1f9ab4aa9..6138576ea90e 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -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
 ----------------------------------------------------------------------



More information about the Python-checkins mailing list