🌐
Real Python
realpython.com › python-t-strings
Python 3.14: Template Strings (T-Strings) – Real Python
July 2, 2025 - Even though it’s possible to use Template as shown in this example, the most convenient way to create t-strings is using literals. As with any attribute, you can access .strings, .interpolations, and .values using the dot notation on an instance of Template: ... >>> name = "Pythonista" >>> site = "realpython.com" >>> template = t"Hello, {name}! Welcome to {site}!" >>> template.strings ('Hello, ', '! Welcome to ', '!') >>> template.interpolations ( Interpolation('Pythonista', 'name', None, ''), Interpolation('realpython.com', 'site', None, '') ) >>> template.values ('Pythonista', 'realpython.com')
🌐
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.
Discussions

Python's new t-strings
When do we get the g-strings? More on reddit.com
🌐 r/programming
43
124
April 21, 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
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
Supporting t-strings from Python 3.14 - Django Internals - Django Forum
t-strings have been merged into Python 3.14 for its beta 1 release (May 7). Since reading the PEP and its associated example repo, I’ve been noodling about how Django could use t-strings. I am sure others are eager to think about this too. Here are some ideas, I wonder what everyone else thinks. More on forum.djangoproject.com
🌐 forum.djangoproject.com
5
May 14, 2025
🌐
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 - I’m excited about t-strings because they make string processing safer and more flexible. In this post, I’ll explain what t-strings are, why they were added to Python, and how you can use them.
🌐
Python
docs.python.org › 3 › library › string.templatelib.html
string.templatelib — Support for template string literals
If multiple strings are passed consecutively, they will be concatenated into a single value in the strings attribute. For example, the following code creates a Template with a single final string:
🌐
Reddit
reddit.com › r/programming › python's new t-strings
r/programming on Reddit: Python's new t-strings
April 21, 2025 - A t-string expression constructs an object of type Template, containing all string fragments and evaluated values that formed the expression. Any further code can do with this Template whatever it wants. What is the primary use case, like if someone wrote some small library in python with a few functions, how do t-strings fit in there?
🌐
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
🌐
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:57 Well, we wanted to show some basic examples like, hey, t-strings have a syntax that looks a lot like f-strings. 45:03 How could you build f-strings on top of t-strings? 45:05 So there is an F paren-paren method that's implemented here that just kind of helps you understand, okay, I'm writing dynamic code to do the thing that f-strings would have done at compile time anyway. ... 45:20 And I'm excited about this, you know, structured logging that Python has shipped a logging cookbook for a long time since the Python 2.something era.
Find elsewhere
🌐
YouTube
youtube.com › watch
Python 3.14: The NEW T-strings are Awesome - YouTube
In today's video we're going to learn about template strings in Python using the new T-string syntax introduced in Python 3.14!▶ Become job-ready with Python...
Published   September 16, 2025
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.

🌐
Python
docs.python.org › 3 › library › string.html
string — Common string operations
July 4, 2010 - A primary use case for template strings is for internationalization (i18n) since in that context, the simpler syntax and functionality makes it easier to translate than other built-in string formatting facilities in Python. As an example of a library built on template strings for i18n, see the flufl.i18n package.
🌐
InfoWorld
infoworld.com › home › software development › programming languages › python
How to use template strings in Python 3.14 | InfoWorld
September 26, 2025 - If this were a conventional f-string, we could print(template) and get Hello, Davis as the output. But if we try printing a t-string, we don’t get a string. Instead, we get a Python object representation:
🌐
Python Snacks
pythonsnacks.com › p › python-3-14-presents-t-strings
An Introduction to t-strings in Python 3.14
July 27, 2025 - » t-strings currently don’t support mathematical operations, inline expressions, string operations and if-else logic, unlike f-strings and .format() Python 3.14 (Beta 4) introduces t-strings, a new secure string formatting feature.
🌐
Real Python
realpython.com › lessons › 314-introducing-t-strings
Introducing Python T-Strings (Video) – Real Python
In the previous lesson, I showed you the new functools placeholder feature when calling partial to create a function alias. In this lesson, I’ll demonstrate t-strings. The “t” in t-strings stands for “template” under the covers. A t-string uses the…
Published   October 7, 2025
🌐
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?

🌐
W3Schools
w3schools.com › python › python_strings.asp
Python Strings
Strings in python are surrounded by either single quotation marks, or double quotation marks. ... print("It's alright") print("He is called 'Johnny'") print('He is called "Johnny"') Try it Yourself »
🌐
Django Forum
forum.djangoproject.com › django internals
Supporting t-strings from Python 3.14 - Django Internals - Django Forum
May 14, 2025 - t-strings have been merged into Python 3.14 for its beta 1 release (May 7). Since reading the PEP and its associated example repo, I’ve been noodling about how Django could use t-strings. I am sure others are eager to t…
🌐
Real Python
realpython.com › lessons › python-t-strings-summary
Exploring Python T-Strings (Summary) (Video) – Real Python
In the previous lesson, I showed even more t-string handling techniques. In this lesson, I’ll summarize the course and point you at other resources. T-strings are f-string-like mechanisms with fine-grained control on how you process the parts of a…
Published   August 5, 2025
🌐
Python
peps.python.org › pep-0750
PEP 750 – Template Strings - Python Enhancement Proposals
July 8, 2024 - Template strings address these problems by providing developers with access to the string and its interpolated values. For example, imagine we want to generate some HTML.
🌐
Medium
medium.com › @backendbyeli › template-string-literals-t-strings-a-game-changer-in-python-3-14-96ef09f1a1c3
Template String Literals (t-Strings) in Python 3.14 Explained | Medium
October 29, 2025 - # Traditional approach with f-strings def generate_welcome(name): return f"Welcome back, {name}! You have {get_notifications()} new messages." # New t-string approach… ... Writing about modern backend development — from Node.js and Python to Go, Rust,Java, Php and .NET.