🌐
GitHub
github.com › t-strings › awesome-t-strings
GitHub - t-strings/awesome-t-strings · GitHub
A curated list of resources, tools, libraries, and examples for Python's Template Strings (t-strings) introduced in Python 3.14
Starred by 68 users
Forked by 4 users
Languages   Python
🌐
GitHub
github.com › t-strings › pep750-examples
GitHub - t-strings/pep750-examples: Examples of using t-strings as defined in PEP 750
This repository contains full implementations of the code examples described in PEP 750: Template Strings. It also includes a suite of tests to make sure the examples are correct.
Starred by 52 users
Forked by 5 users
Languages   Python 99.9% | Shell 0.1% | Python 99.9% | Shell 0.1%
Discussions

Template strings in Python 3.14: an useful new feature or just an extra syntax?
This seems useful to formalize what templating systems already do. More on reddit.com
🌐 r/Python
98
167
May 1, 2025
How are Python 3.14 t-strings different than f-strings - Stack Overflow
Python 3.14 is introducing template strings, so-called t-strings. Can someone explain how these differ from f-strings? What new problems are t-strings helping developers solve? More on stackoverflow.com
🌐 stackoverflow.com
Python’s new t-strings
db.execute("QUERY WHERE name = ?", (name,)) with · db.execute(t"QUERY WHERE name = {name}") Does the benefit from this syntactic sugar outweigh the added complexity of a new language feature? I think it does in this case for two reasons: More on news.ycombinator.com
🌐 news.ycombinator.com
466
620
May 1, 2025
T-Strings: What will you do?
Wake me up when we get g-strings More on reddit.com
🌐 r/Python
88
129
September 19, 2025
🌐
Real Python
realpython.com › python-t-strings
Python 3.14: Template Strings (T-Strings) – Real Python
July 2, 2025 - In this example, you can identify each part of the template, including the static text, field, format specifier, and conversion flag. This string formatting tool is especially useful when you’re building custom formatting logic, parsers, or templating tools. Python 3.14 comes with yet another string processing tool: template strings, or t-strings, introduced in PEP 750.
🌐
GitHub
github.com › t-strings › tdom
GitHub - t-strings/tdom: A 🤘 rockin' t-string HTML templating system for Python 3.14.
One particularly useful pattern is to build class-based components with dataclasses: from string.templatelib import Template from dataclasses import dataclass, field from typing import Any, Iterable from tdom import html @dataclass class Card: children: Template title: str subtitle: str | None = None def __call__(self) -> Template: return t""" <div class='card'> <h2>{self.title}</h2> {self.subtitle and t'<h3>{self.subtitle}</h3>'} <div class="content">{self.children}</div> </div> """ result = html(t"<{Card} title='My Card' subtitle='A subtitle'><p>Card content</p></{Card}>") # <div class='card'> # <h2>My Card</h2> # <h3>A subtitle</h3> # <div class="content"><p>Card content</p></div> # </div>
Starred by 135 users
Forked by 7 users
Languages   Python 99.5% | Just 0.5%
🌐
Snarky
snarky.ca › unravelling-t-strings
Unravelling t-strings
May 16, 2025 - We parsed f"Hello, {name}! Conversions like {name!r} and format specs like {name:<6} work!" into Template("Hello, ", Interpolation(name, "name"), "! Conversions like ", Interpolation(name, "name", "r"), " and format specs like ", Interpolation(name, "name", format_spec="<6")," work!"). We were then able to use our f_yeah() function to convert the t-string into what an equivalent f-string would have looked like. The actual code to use to test this in Python 3.14 with an actual t-string is the following (PEP 750 has its own version of converting a t-string to an f-string which greatly inspired my example):
🌐
Davepeck
davepeck.org › 2025 › 04 › 11 › pythons-new-t-strings
Python's new t-strings | Dave Peck
April 11, 2025 - By giving developers access to the parts of strings, t-strings make it possible to write code that processes strings in powerful and safe ways. Since they were introduced in Python 3.6, f-strings have become very popular. Developers use them for everything…
🌐
Python
docs.python.org › 3 › library › string.templatelib.html
string.templatelib — Support for template string literals
While literal syntax is the most common way to create a Template, it is also possible to create them directly using the constructor: >>> from string.templatelib import Interpolation, Template >>> cheese = 'Camembert' >>> template = Template( ... 'Ah!
Find elsewhere
🌐
Reddit
reddit.com › r/python › template strings in python 3.14: an useful new feature or just an extra syntax?
r/Python on Reddit: Template strings in Python 3.14: an useful new feature or just an extra syntax?
May 1, 2025 -

Python foundation just accepted PEP 750 for template strings, or called t-strings. It will come with Python 3.14.

There are already so many methods for string formatting in Python, why another one??

Here is an article to dicsuss its usefulness and motivation. What's your view?

Top answer
1 of 2
21

The new t-strings ease the creation of strings meant to represent other languages, embedded in a Python program, while preserving information about the variables and expressions interpolated so that specialized glue/connection code to that other language can do things like syntax checking, character escaping, security auditing, and in general adding specific punctuation to those interpolated values. The full proposal is in PEP 750.

The important thing to have in mind is that a t-string by itself adds no value. Just when combined with a call to a consumer of that string, which might be a SQL connector, an HTML renderer, or even a regular expression template, the extra information - when compared with an f-string - present in the t-string will add value.

In other words, while an f-string is immediately rendered into an immutable, plain str instance when found, a t-string is converted into a Template object which preserves information about the individual interpolated values (and if needed, their original expressions). This template instance is then passed to a call which will act on the string, special casing these values. For example, a t-string aware SQL connector can automatically escape in a safe way all interpolated values, mitigating any possible SQL injection vulnerability.

For a simple usage example not in the docs, here is a simple interactive mode snippet which will wrap the templated values in a CSI ANSI code sequence to change the terminal color. I set up constant values with the color codes I am using for the example:


In [26]: from string import templatelib

In [27]: red = 31; reset=0; green = 32

In [28]: a = t"The next {red}text{reset} should be {green}in another color{reset}"

In [29]: for part in a:
    ...:     if isinstance(part, templatelib.Interpolation):
    ...:         part = f"\x1b[{part.value}m"
    ...:     # else: -> implies 'part' is a regular str object
    ...:     print(part, end="")
    ...: 

This prints some text colored according to the example in a functional terminal (not windows CMD).

Still in this summary, it is worth noting that t-strings, like f-strings are eagerly evaluated. This means the values for the variables in the interpolated expressions are used as they are when the line of code where the t-string is expressed is executed: even if the variable changes later on, the orignal value is saved in the template object. The converse behavior, having the values dynamically change with the values assigned to the variables in the expressions was reasoned out in the discussions leading to the feature. (check the rejected ideas session in PEP 750)

2 of 2
2

The What's New page has various examples, and some potential applications of template strings.

With this in place, developers can write template systems to sanitize SQL, make safe shell operations, improve logging, tackle modern ideas in web development (HTML, CSS, and so on), and implement lightweight, custom business DSLs.

from string.templatelib import Template, Interpolation

def lower_upper(template: Template) -> str:
    """Render static parts lowercased and interpolations uppercased."""
    parts: list[str] = []
    for item in template:
        if isinstance(item, Interpolation):
            parts.append(str(item.value).upper())
        else:
            parts.append(item.lower())
    return "".join(parts)

name = "world"
assert lower_upper(t"HELLO {name}") == "hello WORLD"

The main difference is the following:

Compared to using an f-string, the html function has access to template attributes containing the original information: static strings, interpolations, and values from the original scope.

🌐
BIG TIME T-STRINGS!
bigtime.t-strings.help
BIG TIME T-STRINGS!
Here's a list of public repositories on GitHub that make use of Python 3.14's new t-string feature, ranked by just how BIG TIME their use really is.
🌐
Talk Python To Me
talkpython.fm › episodes › show › 505 › t-strings-in-python-pep-750
Episode #505 - t-strings in Python (PEP 750) | Talk Python To Me Podcast
May 13, 2025 - 44:09 So in the HTML case, and you can actually find examples of this, for example, in the PEP 750 examples repository, there's an HTML function there and it has a bunch of nice features, but you're returning an HTML element back from the code that processes the T-string, you don't, in fact, have to grab a string out of a T-string right away or ever if you don't want to. 44:30 So there's an immense amount of flexibility here that we're excited to see people use. 44:35 Yeah. Dave, under your account on GitHub, Dave Peck.
🌐
GitHub
github.com › t-strings
t-strings · GitHub
Accessibility-focused DOM testing library for tdom, built with modern Python 3.14+. There was an error while loading. Please reload this page. t-strings/aria-testing’s past year of commit activity ... There was an error while loading. Please reload this page. t-strings/awesome-t-strings’s past year of commit activity ... There was an error while loading. Please reload this page. t-strings/pep750-examples’s past year of commit activity
🌐
Python Morsels
pythonmorsels.com › t-strings-in-python
T-strings: Python's Fifth String Formatting Technique? - Python Morsels
October 20, 2025 - Anytime you're designing a tool where you need to pre-process smaller input strings before combining them to a larger string, like escaping SQL, HTML, or regular expressions, you might want to use a t-string. Or, if you need to delay string interpolation for some other reason, like Python's logging module does, t-strings could come in handy in that case as well.
🌐
Hacker News
news.ycombinator.com › item
Python’s new t-strings | Hacker News
May 1, 2025 - db.execute("QUERY WHERE name = ?", (name,)) with · db.execute(t"QUERY WHERE name = {name}") Does the benefit from this syntactic sugar outweigh the added complexity of a new language feature? I think it does in this case for two reasons:
🌐
GitHub
github.com › Asabeneh › 30-Days-Of-Python › blob › master › 04_Day_Strings › 04_strings.md
30-Days-Of-Python/04_Day_Strings/04_strings.md at master · Asabeneh/30-Days-Of-Python
# String could be made using a single or double quote,"Hello, World!" print(greeting) # Hello, World! print(len(greeting)) # 13 sentence = "I hope you are enjoying 30 days of Python Challenge" print(sentence) Multiline string is created by using triple single (''') or triple double quotes ("""). See the example below.
Author   Asabeneh
🌐
GitHub
github.com › enthought › Python-2.7.3 › blob › master › Lib › string.py
Python-2.7.3/Lib/string.py at master · enthought/Python-2.7.3
"""A collection of string operations (most are no longer used). ... Warning: most of the code you see here isn't normally used nowadays. Beginning with Python 1.6, many of these functions are implemented as
Author   enthought
🌐
Python
peps.python.org › pep-0787
PEP 787 – Safer subprocess usage using t-strings | peps.python.org
April 13, 2025 - When subprocess.Popen is called without shell=True, t-string support would still provide subprocess with a more ergonomic syntax. For example:
🌐
InfoWorld
infoworld.com › home › software development › programming languages › python
How to use template strings in Python 3.14 | InfoWorld
September 26, 2025 - string.templatelib is a new module in the standard library for Python 3.14 that holds the types we need: Template for the type hint to the function, and Interpolation to check the elements we iterate through. However, we don’t need string.templatelib to make template strings. Those we can construct just by using the t-string syntax anywhere in our code. For a better example of how useful and powerful template strings can be, let’s look at a task that would be a good deal more difficult without them.
🌐
Reddit
reddit.com › r/python › t-strings: what will you do?
r/Python on Reddit: T-Strings: What will you do?
September 19, 2025 -

Good evening from my part of the world!

I'm excited with the new functionality we have in Python 3.14. I think the feature that has caught my attention the most is the introduction of t-strings.

I'm curious, what do you think will be a good application for t-strings? I'm planning to use them as better-formatted templates for a custom message pop-up in my homelab, taking information from different sources to format for display. Not reinventing any functionality, but certainly a cleaner and easier implementation for a message dashboard.

Please share your ideas below, I'm curious to see what you have in mind!