diff options
author | Stanley <46876382+slateny@users.noreply.github.com> | 2022-09-21 12:57:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-21 12:57:03 (GMT) |
commit | 4b81139aac3fa11779f6eedb6e621bde29e64b30 (patch) | |
tree | 0eda62e34a20742fc89a4911ff1c51be9e104fcf /Doc/tutorial | |
parent | 5a32eeced2c537c13613dd4ff5b2767a37037294 (diff) | |
download | cpython-4b81139aac3fa11779f6eedb6e621bde29e64b30.zip cpython-4b81139aac3fa11779f6eedb6e621bde29e64b30.tar.gz cpython-4b81139aac3fa11779f6eedb6e621bde29e64b30.tar.bz2 |
gh-81039: Add small example of f-string's "=}" to tutorial (gh-92291)
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/inputoutput.rst | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index d341400..de84ab7 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: |