-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-132661: Document t-strings and templatelib
#135229
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
Changes from 1 commit
5a8dbfa
09a1e9e
ec44c2b
d8904b6
550aa6d
a20e058
1f30739
d935dd6
1e47362
7b660be
00a535d
fcd74e6
a796f5d
21d337c
d043381
9a0a301
f2e5ca4
8484b81
56ef703
5a8cf1b
127ebc6
73e1222
530cb6d
eaec534
05b5beb
680189a
71ddbf4
1c0ed70
ecc86c3
64c6758
16a995d
7f376d7
9e87880
574c29c
6f0f95a
95df68f
e562c4e
25d9a6f
72b36fe
15dd810
fd38fba
84dbc16
54914fe
7eca01e
687c506
3827427
79169d1
5d7491c
115eaa5
04c2e8d
2da418b
9070840
5af0434
437320d
d69d8e0
ae6f072
6446762
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…mplate
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2673,9 +2673,9 @@ For example: | |||||||||||||||
lead to a number of common errors (such as failing to display tuples and | ||||||||||||||||
dictionaries correctly). Using the newer :ref:`formatted string literals | ||||||||||||||||
<f-strings>`, the :meth:`str.format` interface, or :ref:`template strings | ||||||||||||||||
<template-strings>` may help avoid these errors. Each of these | ||||||||||||||||
alternatives provides their own trade-offs and benefits of simplicity, | ||||||||||||||||
flexibility, and/or extensibility. | ||||||||||||||||
($-strings) <template-strings-pep292>` may help avoid these errors. | ||||||||||||||||
Each of these alternatives provides their own trade-offs and benefits of | ||||||||||||||||
simplicity, flexibility, and/or extensibility. | ||||||||||||||||
Comment on lines
+2678
to
+2680
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (part 2). I don't think we need to mention
Suggested change
|
||||||||||||||||
|
||||||||||||||||
String objects have one unique built-in operation: the ``%`` operator (modulo). | ||||||||||||||||
This is also known as the string *formatting* or *interpolation* operator. | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -790,10 +790,20 @@ Nesting arguments and more complex examples:: | |
|
||
|
||
|
||
.. _template-strings: | ||
.. _template-strings-pep292: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will break anchor references within the page: https://docs.python.org/3/library/string.html#template-strings Are we OK with doing so? |
||
|
||
Template strings | ||
---------------- | ||
Template strings ($-strings) | ||
---------------------------- | ||
|
||
.. note:: | ||
|
||
The :class:`~string.Template` class described here was introduced in Python | ||
2.4. It is entirely unrelated to, and should *not* be confused with, the | ||
new :ref:`Template Strings <template-strings>` feature and | ||
:ref:`t-string literal syntax <t-strings>` introduced in Python 3.14 and | ||
originally described in :pep:`750`. Python's t-string literals evaluate to | ||
instances of a different :class:`~string.templatelib.Template` class, which | ||
is found in the :mod:`string.templatelib` module. | ||
|
||
Template strings provide simpler string substitutions as described in | ||
:pep:`292`. A primary use case for template strings is for | ||
|
davepeck marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -14,6 +14,17 @@ | |||||||
:ref:`Format strings <f-strings>` | ||||||||
|
||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
.. _template-strings: | ||||||||
|
||||||||
Template strings | ||||||||
---------------- | ||||||||
|
||||||||
Documentation forthcoming for PEP 750 template strings, also known as t-strings. | ||||||||
|
||||||||
.. versionadded:: 3.14 | ||||||||
|
||||||||
|
||||||||
.. _templatelib-template: | ||||||||
|
||||||||
Template | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(part 1). I don't think we need to mention
string.Template
// 292 here.