Skip to content

Commit 5a8cf1b

Browse files
committed
Clarify distinction between string.Template and string.templatelib.Template
1 parent 56ef703 commit 5a8cf1b

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

Doc/library/stdtypes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,9 +2673,9 @@ For example:
26732673
lead to a number of common errors (such as failing to display tuples and
26742674
dictionaries correctly). Using the newer :ref:`formatted string literals
26752675
<f-strings>`, the :meth:`str.format` interface, or :ref:`template strings
2676-
<template-strings>` may help avoid these errors. Each of these
2677-
alternatives provides their own trade-offs and benefits of simplicity,
2678-
flexibility, and/or extensibility.
2676+
($-strings) <template-strings-pep292>` may help avoid these errors.
2677+
Each of these alternatives provides their own trade-offs and benefits of
2678+
simplicity, flexibility, and/or extensibility.
26792679

26802680
String objects have one unique built-in operation: the ``%`` operator (modulo).
26812681
This is also known as the string *formatting* or *interpolation* operator.

Doc/library/string.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,20 @@ Nesting arguments and more complex examples::
790790

791791

792792

793-
.. _template-strings:
793+
.. _template-strings-pep292:
794794

795-
Template strings
796-
----------------
795+
Template strings ($-strings)
796+
----------------------------
797+
798+
.. note::
799+
800+
The :class:`~string.Template` class described here was introduced in Python
801+
2.4. It is entirely unrelated to, and should *not* be confused with, the
802+
new :ref:`Template Strings <template-strings>` feature and
803+
:ref:`t-string literal syntax <t-strings>` introduced in Python 3.14 and
804+
originally described in :pep:`750`. Python's t-string literals evaluate to
805+
instances of a different :class:`~string.templatelib.Template` class, which
806+
is found in the :mod:`string.templatelib` module.
797807

798808
Template strings provide simpler string substitutions as described in
799809
:pep:`292`. A primary use case for template strings is for

Doc/library/string.templatelib.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
:ref:`Format strings <f-strings>`
1515

1616

17+
18+
.. _template-strings:
19+
20+
Template strings
21+
----------------
22+
23+
Documentation forthcoming for PEP 750 template strings, also known as t-strings.
24+
25+
.. versionadded:: 3.14
26+
27+
1728
.. _templatelib-template:
1829

1930
Template

0 commit comments

Comments
 (0)