# PEP750: Template Strings (new updates)

**URL:** <https://discuss.python.org/t/pep750-template-strings-new-updates/71594>\
**Category:** PEPs\
**Created:** [November 18, 2024, 5:44pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594 "2024-11-18T17:44:56Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![barry](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barry/32/42_2.png) [@barry](https://discuss.python.org/u/barry)\
**Post date:** [March 14, 2025, 3:27pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/121 "2025-03-14T15:27:11Z")

</div>

Yes, it shouldn’t be anything major.

---

<div class="post-metadata">

**Author:** ![pablogsal](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pablogsal/32/32246_2.png) [@pablogsal](https://discuss.python.org/u/pablogsal)\
**Post date:** [April 6, 2025, 9:34pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/122 "2025-04-06T21:34:05Z")

</div>

We have published the list of changes here: [PEP 750 -- Template Strings · Issue #275 · python/steering-council · GitHub](https://github.com/python/steering-council/issues/275#issuecomment-2781683333)

As we mention in the issue, you can make these changes in parallel to the implementation (so don’t wait until the PEP is modified and is officially approved to propose and iterate over the PR). But landing the PR requires the PEP approved.

---

<div class="post-metadata">

**Author:** ![samuel.wing](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/samuel.wing/32/27073_2.png) [@samuel.wing](https://discuss.python.org/u/samuel.wing)\
**Post date:** [April 6, 2025, 11:17pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/123 "2025-04-06T23:17:04Z")

</div>

I’m super excited for this feature! Is this still expected to make it into 3.14?

@dkp @lys.nikolaou would it help if I attempt to make a PR tomorrow to the tstrings branch of Lysandros’s fork that does the rename of expr/conv and the move of the Template/Interpolation types?

---

<div class="post-metadata">

**Author:** ![hugovk](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/hugovk/32/14505_2.png) [@hugovk](https://discuss.python.org/u/hugovk)\
**Post date:** [April 7, 2025, 4:49am UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/124 "2025-04-07T04:49:28Z")

</div>

> [@samuel.wing](#):
>
> Is this still expected to make it into 3.14?

That’s the plan, there’s a month until the feature freeze on [2025-05-06](https://peps.python.org/pep-0745/).

---

<div class="post-metadata">

**Author:** ![lys.nikolaou](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/lys.nikolaou/32/2339_2.png) [@lys.nikolaou](https://discuss.python.org/u/lys.nikolaou)\
**Post date:** [April 7, 2025, 9:52am UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/125 "2025-04-07T09:52:29Z")

</div>

Sure, I’d be happy to accept a PR with the requested changes.

---

<div class="post-metadata">

**Author:** ![samuel.wing](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/samuel.wing/32/27073_2.png) [@samuel.wing](https://discuss.python.org/u/samuel.wing)\
**Post date:** [April 7, 2025, 7:28pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/126 "2025-04-07T19:28:45Z")

</div>

My PR is posted. The chances of this making tomorrow’s alpha are pretty slim, correct?

---

<div class="post-metadata">

**Author:** ![AA-Turner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/aa-turner/32/4979_2.png) [@AA-Turner](https://discuss.python.org/u/AA-Turner)\
**Post date:** [April 7, 2025, 8:09pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/127 "2025-04-07T20:09:32Z")

</div>

The implementation will only be merged if the PEP is accepted, which hasn’t happened yet:

> landing the PR requires the PEP approved.

Per Hugo’s note above, there’s still a month before actual feature freeze, so there’s no mad rush (yet!).

A

---

<div class="post-metadata">

**Author:** ![samuel.wing](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/samuel.wing/32/27073_2.png) [@samuel.wing](https://discuss.python.org/u/samuel.wing)\
**Post date:** [April 7, 2025, 8:31pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/128 "2025-04-07T20:31:41Z")

</div>

Ah okay, so it will most likely first ship in beta 1. Thanks!

---

<div class="post-metadata">

**Author:** ![dkp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dkp/32/20413_2.png) [@dkp](https://discuss.python.org/u/dkp)\
**Post date:** [April 10, 2025, 4:13pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/129 "2025-04-10T16:13:36Z")

</div>

Thanks, @pablogsal!

[PEP 750](https://peps.python.org/pep-0750/) has been updated with a first cut addressing steering council feedback. Thanks to everyone who helped!

If you’d like to play with t-strings, [see Lysandros’ branch](https://github.com/lysnikolaou/cpython/tree/tstrings) or grab a [docker image](https://github.com/users/davepeck/packages/container/python/393057990?tag=tstrings-fa4b531-bullseye). The [`pep750-examples` repo](https://github.com/davepeck/pep750-examples) has also been updated; it includes a devcontainer.

---

<div class="post-metadata">

**Author:** ![pablogsal](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pablogsal/32/32246_2.png) [@pablogsal](https://discuss.python.org/u/pablogsal)\
**Post date:** [April 10, 2025, 5:24pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/130 "2025-04-10T17:24:43Z")

</div>

The Steering Council reviewed today [PEP 750: Updates requested by the Steering Council by davepeck · Pull Request #4351 · python/peps · GitHub](https://github.com/python/peps/pull/4351) and we are happy with the changes so we are formally approving the PEP. Congratulations yet again! 🙂

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/thiefmaster/32/1067_2.png) [@ThiefMaster](https://discuss.python.org/u/ThiefMaster)\
**Post date:** [April 10, 2025, 5:42pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/131 "2025-04-10T17:42:22Z")

</div>

Looks really nice, but two things I really found surprising:

- No i18n example in the PEP itself. Like, that seems to be THE perfect usecase for this. No more `_('Hello {}').format(name)` - instead, you do `_(t'Hello {name}')` and all this needs is your gettext function (and string extractor) to have support for it (which sounds pretty trivial)
- Convoluted logging example: `logging.info(_(t"User {action}: {amount:.2f} {item}"))`:
  1. `_()` is typically i18n, so that shortcut is weird
  2. People will absolutely forget this and then wonder why their logging is not working as expected. Instead, why not support this inside logging (I think the example repo actually does it that way, but the PEP will be read by MANY more people)

---

<div class="post-metadata">

**Author:** ![barry](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barry/32/42_2.png) [@barry](https://discuss.python.org/u/barry)\
**Post date:** [April 10, 2025, 8:18pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/132 "2025-04-10T20:18:58Z")

</div>

> [@ThiefMaster](#):
>
> No i18n example in the PEP itself.

I raised this during the [first round of discussions](https://discuss.python.org/t/pep-750-tag-strings-for-writing-domain-specific-languages/60408/85) so won’t repeat myself here except to point you to the [flufl.i18n](https://flufli18n.readthedocs.io/en/stable/) library I maintain.

---

<div class="post-metadata">

**Author:** ![dkp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dkp/32/20413_2.png) [@dkp](https://discuss.python.org/u/dkp)\
**Post date:** [April 10, 2025, 8:52pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/133 "2025-04-10T20:52:05Z")

</div>

> [@ThiefMaster](#):
>
> Convoluted logging example

Yeah.

I wrote the [first logging example](https://peps.python.org/pep-0750/#approach-1-custom-log-messages) in the PEP to _directly_ parallel Python’s current documentation on [how to implement structured logging](https://docs.python.org/3/howto/logging-cookbook.html#implementing-structured-logging). That documentation also adopts `_` and has the drawback you mentioned: it’s easy to forget.

I have a strong preference for the [second logging example](https://peps.python.org/pep-0750/#approach-2-custom-formatters) in the PEP but felt like it was important to work with existing documentation first.

Maybe it’s worth revisiting this as part of our work towards documenting t-strings for 3.14’s release.

---

<div class="post-metadata">

**Author:** ![ncoghlan](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ncoghlan/32/14266_2.png) [@ncoghlan](https://discuss.python.org/u/ncoghlan)\
**Post date:** [April 11, 2025, 3:37am UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/134 "2025-04-11T03:37:35Z")

</div>

> [@dkp](#):
>
> That documentation also adopts `_` and has the drawback you mentioned: it’s easy to forget.

FWIW, when doing logging customisation on input (which is the only way you can do it consistently in a library that doesn’t control the overall logging config), I don’t do the wrapping at every call site, but provide a logging facade that mirrors the stdlib logging APIs.

Adding t-string support would happen in the facade layer rather than at every call site.

---

<div class="post-metadata">

**Author:** ![timhoffm](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/timhoffm/32/19468_2.png) [@timhoffm](https://discuss.python.org/u/timhoffm)\
**Post date:** [April 14, 2025, 4:28pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/135 "2025-04-14T16:28:49Z")

</div>

Naming question: Is `Template` alone readable enough, or should we spend some more letters for the more specific `TemplateStr`? Sure, the fully qualified name `string.templatelib.Template` is unambiguous, but I anticipate that it will typically be imported via `from string.templatelib import Template` so that typical code usage is (snippets taken from the PEP)

```python
template: Template = t"Hello {name}"
# or
def html(template: Template) -> Element:

```

and there I would find `TemplateStr` more readable compared to a generic `Template`

```python
template: TemplateStr = t"Hello {name}"
# or
def html(template: TemplateStr) -> Element:

```

---

<div class="post-metadata">

**Author:** ![samuel.wing](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/samuel.wing/32/27073_2.png) [@samuel.wing](https://discuss.python.org/u/samuel.wing)\
**Post date:** [April 14, 2025, 4:44pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/136 "2025-04-14T16:44:53Z")

</div>

I would prefer TemplateStr or TemplateString to deconflict with string.Template. However, the PEP has already been accepted so I don’t think it can change?

---

<div class="post-metadata">

**Author:** ![jamestwebber](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamestwebber/32/12799_2.png) [@jamestwebber](https://discuss.python.org/u/jamestwebber)\
**Post date:** [April 14, 2025, 4:56pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/137 "2025-04-14T16:56:27Z")

</div>

The PEP cannot change, it is a historical document. The implementation can be updated with a new PEP, but you will have to convince others that this change is worth making.

I’m not totally sure what your comment means specifically, but it is worth searching the discussion to see if this came up and was resolved already.

---

<div class="post-metadata">

**Author:** ![barry](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barry/32/42_2.png) [@barry](https://discuss.python.org/u/barry)\
**Post date:** [April 14, 2025, 5:10pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/138 "2025-04-14T17:10:32Z")

</div>

> [@timhoffm](#):
>
> Sure, the fully qualified name `string.templatelib.Template` is unambiguous, but I anticipate that it will typically be imported via `from string.templatelib import Template`

There’s always “import as” to handle any ambiguity.

---

<div class="post-metadata">

**Author:** ![timhoffm](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/timhoffm/32/19468_2.png) [@timhoffm](https://discuss.python.org/u/timhoffm)\
**Post date:** [April 14, 2025, 6:08pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/139 "2025-04-14T18:08:24Z")

</div>

I’ve searched here, in [PEP 750: Tag Strings For Writing Domain-Specific Languages - PEPs - Discussions on Python.org](https://discuss.python.org/t/pep-750-tag-strings-for-writing-domain-specific-languages/60408/312) and the PEP itself and found no discussion on the naming of `Template`. That’s why I’m bringing up the question here - Addmittedly I haven’t read all posts but tried different search patterns, so I might have overlooked something. I’d be happy to see this has been discussed and decided before.

> There’s always “import as” to handle any ambiguity.

Sure. The question is, what is the intended naming in user code. A single user can always do `from string.templatelib import Template as TemplateStr` to have a better name. But IMHO we shouldn’t generally recommend renaming via `as` if we have the possibility to choose the name ourselves. Naming is important. There are arguments for both `Template` and `TemplateStr`. I just want to make sure this decision is conscious.

---

<div class="post-metadata">

**Author:** ![dg-pb](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dg-pb/32/16248_2.png) [@dg-pb](https://discuss.python.org/u/dg-pb)\
**Post date:** [April 14, 2025, 6:16pm UTC](https://discuss.python.org/t/pep750-template-strings-new-updates/71594/140 "2025-04-14T18:16:23Z")

</div>

> [@timhoffm](#):
>
> TemplateStr

Maybe something closer to `TTemplate` if that is an issue?

`TemplateStr` is ambiguous as it can as well mean `string.Template`. Also not very pleasant.

[Previous page](https://discuss.python.org/t/pep750-template-strings-new-updates/71594.md?page=6)

[Next page](https://discuss.python.org/t/pep750-template-strings-new-updates/71594.md?page=8)
