@@ -134,7 +134,7 @@ see the `Raw Template Strings`_ section below for more information.
134134The ``Template `` Type
135135---------------------
136136
137- Template strings evaluate to an instance of a new immutable type,
137+ Template strings evaluate to an instance of a new immutable type,
138138``string.templatelib.Template ``:
139139
140140.. code-block :: python
@@ -233,10 +233,10 @@ The ``expression`` attribute is the *original text* of the interpolation:
233233 template = t" Hello {name} "
234234 assert template.interpolations[0 ].expression == " name"
235235
236- We expect that the ``expression `` attribute will not be used in most template
237- processing code. It is provided for completeness and for use in debugging and
238- introspection. See both the `Common Patterns Seen in Processing Templates `_
239- section and the `Examples `_ section for more information on how to process
236+ We expect that the ``expression `` attribute will not be used in most template
237+ processing code. It is provided for completeness and for use in debugging and
238+ introspection. See both the `Common Patterns Seen in Processing Templates `_
239+ section and the `Examples `_ section for more information on how to process
240240template strings.
241241
242242The ``conversion `` attribute is the :ref: `optional conversion <python:formatstrings >`
@@ -287,7 +287,7 @@ did not round the value to two decimal places when processed.
287287The ``Template.values `` Property
288288--------------------------------
289289
290- The ``Template.values `` property is a shortcut for accessing the ``value ``
290+ The ``Template.values `` property is a shortcut for accessing the ``value ``
291291attribute of each ``Interpolation `` in the template and is equivalent to:
292292
293293.. code-block :: python
@@ -351,8 +351,8 @@ in the output of the ``__iter__()`` method:
351351 # However, the strings attribute contains empty strings:
352352 assert template.strings == (" " , " " , " " )
353353
354- Template processing code can choose to work with any combination of
355- ``strings ``, ``interpolations ``, ``values ``, and ``__iter__() `` based on
354+ Template processing code can choose to work with any combination of
355+ ``strings ``, ``interpolations ``, ``values ``, and ``__iter__() `` based on
356356requirements and convenience.
357357
358358
@@ -464,10 +464,10 @@ In particular, ``t'{expression=}'`` is treated as ``t'expression={expression!r}'
464464 assert template.interpolations[0 ].value == " World"
465465 assert template.interpolations[0 ].conversion == " r"
466466
467- If a separate format string is also provided, ``t'{expression=:fmt} `` is treated
467+ If a separate format string is also provided, ``t'{expression=:fmt} `` is treated
468468instead as ``t'expression={expression!s:fmt}' ``.
469469
470- Whitespace is preserved in the debug specifier, so ``t'{expression = }' `` is
470+ Whitespace is preserved in the debug specifier, so ``t'{expression = }' `` is
471471treated as ``t'expression = {expression!r}' ``.
472472
473473
@@ -664,7 +664,7 @@ class. With template strings it is no longer necessary for developers to make
664664sure that their format string and values dictionary are kept in sync; a single
665665template string literal is all that is needed. The ``TemplateMessage ``
666666implementation can automatically extract structured keys and values from
667- the ``Interpolation.expression `` and ``Interpolation.value `` attributes,
667+ the ``Interpolation.expression `` and ``Interpolation.value `` attributes,
668668respectively.
669669
670670
@@ -1243,9 +1243,9 @@ Earlier versions of this PEP proposed that the ``Template`` and ``Interpolation`
12431243types should have their own implementations of ``__eq__ `` and ``__hash__ ``.
12441244
12451245``Templates `` were considered equal if their ``strings `` and ``interpolations ``
1246- were equal; ``Interpolations `` were considered equal if their ``value ``,
1247- ``expression ``, ``conversion ``, and ``format_spec `` were equal. Interpolation
1248- hashing was similar to tuple hashing: an ``Interpolation `` was hashable if and
1246+ were equal; ``Interpolations `` were considered equal if their ``value ``,
1247+ ``expression ``, ``conversion ``, and ``format_spec `` were equal. Interpolation
1248+ hashing was similar to tuple hashing: an ``Interpolation `` was hashable if and
12491249only if its ``value `` was hashable.
12501250
12511251This was rejected because ``Template.__hash__ `` so defined was not useful as a
@@ -1288,8 +1288,8 @@ Enable Full Reconstruction of Original Template Literal
12881288
12891289Earlier versions of this PEP attempted to make it possible to fully reconstruct
12901290the text of the original template string from a ``Template `` instance. This was
1291- rejected as being overly complex. The mapping between template literal source
1292- and the underlying AST is not one-to-one and there are several limitations with
1291+ rejected as being overly complex. The mapping between template literal source
1292+ and the underlying AST is not one-to-one and there are several limitations with
12931293respect to round-tripping to the original source text.
12941294
12951295First, ``Interpolation.format_spec `` defaults to ``"" `` if not provided:
@@ -1303,7 +1303,7 @@ First, ``Interpolation.format_spec`` defaults to ``""`` if not provided:
13031303 assert template2.interpolations[0 ].format_spec == " "
13041304
13051305 Next, the debug specifier, ``= ``, is treated as a special case and is processed
1306- before the AST is created. It is therefore not possible to distinguish
1306+ before the AST is created. It is therefore not possible to distinguish
13071307``t"{expression=}" `` from ``t"expression={expression!r}" ``:
13081308
13091309.. code-block :: python
@@ -1318,9 +1318,9 @@ before the AST is created. It is therefore not possible to distinguish
13181318 assert template2.interpolations[0 ].expression == " value"
13191319 assert template2.interpolations[0 ].conversion == " r"
13201320
1321- Finally, format specifiers in f-strings allow arbitrary nesting. In this PEP
1322- and in the reference implementation, the specifier is eagerly evaluated to
1323- set the ``format_spec `` in the ``Interpolation ``, thereby losing the original
1321+ Finally, format specifiers in f-strings allow arbitrary nesting. In this PEP
1322+ and in the reference implementation, the specifier is eagerly evaluated to
1323+ set the ``format_spec `` in the ``Interpolation ``, thereby losing the original
13241324expressions. For example:
13251325
13261326.. code-block :: python
@@ -1378,8 +1378,8 @@ separate PEP.
13781378Removing ``conversion `` From ``Interpolation ``
13791379----------------------------------------------
13801380
1381- During the authoring of this PEP, we considered removing the ``conversion ``
1382- attribute from ``Interpolation `` and specifying that the conversion should be
1381+ During the authoring of this PEP, we considered removing the ``conversion ``
1382+ attribute from ``Interpolation `` and specifying that the conversion should be
13831383performed eagerly, before ``Interpolation.value `` is set.
13841384
13851385This was done to simplify the work of writing template processing code. The
@@ -1390,8 +1390,8 @@ custom format specifiers. Unlike with format specifiers, there is no
13901390equivalent to Python's :func: `python:format ` built-in. (Instead, we include a
13911391sample implementation of ``convert() `` in the `Examples `_ section.)
13921392
1393- Ultimately we decided to keep the ``conversion `` attribute in the
1394- ``Interpolation `` type to maintain compatibility with f-strings and to allow
1393+ Ultimately we decided to keep the ``conversion `` attribute in the
1394+ ``Interpolation `` type to maintain compatibility with f-strings and to allow
13951395for future extensibility.
13961396
13971397
0 commit comments