mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-81039: Add small example of f-string's "=}" to tutorial (gh-92291)
This commit is contained in:
parent
5a32eeced2
commit
4b81139aac
2 changed files with 12 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue