Skip to content

Commit 9fa905f

Browse files
committed
Specify module location as string.templatelib
1 parent 498c5b7 commit 9fa905f

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

peps/pep-0750.rst

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ Template String Literals
109109

110110
This PEP introduces a new string prefix, ``t``, to define template string literals.
111111
These literals resolve to a new type, ``Template``, found in the standard library
112-
module ``<<TBD>>``.
112+
module ``string.templatelib``.
113113

114114
The following code creates a ``Template`` instance:
115115

116116
.. code-block:: python
117117
118-
from TBD import Template
118+
from string.templatelib import Template
119119
template = t"This is a template string."
120120
assert isinstance(template, Template)
121121
@@ -134,7 +134,8 @@ see the `Raw Template Strings`_ section below for more information.
134134
The ``Template`` Type
135135
---------------------
136136

137-
Template strings evaluate to an instance of a new immutable type, ``<<TBD>>.Template``:
137+
Template strings evaluate to an instance of a new immutable type,
138+
``string.templatelib.Template``:
138139

139140
.. code-block:: python
140141
@@ -192,7 +193,7 @@ The ``Interpolation`` Type
192193
--------------------------
193194

194195
The ``Interpolation`` type represents an expression inside a template string.
195-
Like ``Template``, it is a new class found in the ``<<TBD>>`` module:
196+
Like ``Template``, it is a new class found in the ``string.templatelib`` module:
196197

197198
.. code-block:: python
198199
@@ -315,7 +316,7 @@ interpolations in uppercase:
315316

316317
.. code-block:: python
317318
318-
from TBD import Template, Interpolation
319+
from string.templatelib import Template, Interpolation
319320
320321
def lower_upper(template: Template) -> str:
321322
"""Render static parts lowercased and interpolations uppercased."""
@@ -506,7 +507,7 @@ specifiers like ``:.2f``. The full code is fairly simple:
506507

507508
.. code-block:: python
508509
509-
from TBD import Template, Interpolation
510+
from string.templatelib import Template, Interpolation
510511
511512
def convert(value: object, conv: Literal["a", "r", "s"] | None) -> object:
512513
if conv == "a":
@@ -579,7 +580,7 @@ We can implement an improved version of ``StructuredMessage`` using template str
579580
.. code-block:: python
580581
581582
import json
582-
from TBD import Interpolation, Template
583+
from string.templatelib import Interpolation, Template
583584
from typing import Mapping
584585
585586
class TemplateMessage:
@@ -636,7 +637,7 @@ and a ``ValuesFormatter`` for JSON output:
636637
637638
import json
638639
from logging import Formatter, LogRecord
639-
from TBD import Interpolation, Template
640+
from string.templatelib import Interpolation, Template
640641
from typing import Any, Mapping
641642
642643
@@ -820,7 +821,7 @@ best practice for many template function implementations:
820821

821822
.. code-block:: python
822823
823-
from TBD import Template, Interpolation
824+
from string.templatelib import Template, Interpolation
824825
825826
def process(template: Template) -> Any:
826827
for item in template:
@@ -1228,14 +1229,8 @@ The Final Home for ``Template`` and ``Interpolation``
12281229

12291230
Previous versions of this PEP proposed placing the ``Template`` and
12301231
``Interpolation`` types in: ``types``, ``collections``, ``collections.abc``,
1231-
and even in a new top-level module, ``templatelib``. As of this writing, no core
1232-
team consensus has emerged on the final location for these types. The current
1233-
PEP leaves this open for a final decision.
1234-
1235-
One argument in favor of a new top-level ``templatelib`` module is that it would
1236-
allow for future addition of related methods (like ``convert()``) and for
1237-
potential future template processing code to be added to submodules
1238-
(``templatelib.shell``, etc.).
1232+
and even in a new top-level module, ``templatelib``. The final decision was to
1233+
place them in ``string.templatelib``.
12391234

12401235

12411236
Enable Full Reconstruction of Original Template Literal

0 commit comments

Comments
 (0)