Skip to content

PEP 750: collect spec fixes discovered during final implementation work #4364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions peps/pep-0750.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@ The debug specifier, ``=``, is supported in template strings and behaves similar
to how it behaves in f-strings, though due to limitations of the implementation
there is a slight difference.

In particular, ``t'{value=}'`` is treated as ``t'value={value!r}'``:
In particular, ``t'{value=}'`` is treated as ``t'value={value!r}'``. The first
static string is rewritten from ``""`` to ``"value="`` and the ``conversion``
defaults to ``r``:

.. code-block:: python

Expand All @@ -465,8 +467,11 @@ In particular, ``t'{value=}'`` is treated as ``t'value={value!r}'``:
assert template.interpolations[0].value == "World"
assert template.interpolations[0].conversion == "r"

If a separate format string is also provided, ``t'{value=:fmt}`` is treated
instead as ``t'value={value!s:fmt}'``.
If a conversion is explicitly provided, it is kept: ``t'{value=!s}'``
is treated as ``t'value={value!s}'``.

If a format string is provided without a conversion, the ``conversion``
is set to ``None``: ``t'{value=:fmt}'`` is treated as ``t'value={value:fmt}'``.

Whitespace is preserved in the debug specifier, so ``t'{value = }'`` is
treated as ``t'value = {value!r}'``.
Expand Down