Member-only story
Python
Template Strings in Python 3.14: An Unnecessary New Feature?
An honest review of its usage and potential
The incoming Python 3.14 didn’t have any big syntax updates until there was a surprising resolution on 10 April 2025 from the Python Foundation:
The template string(t-string) syntax (suggested by PEP 750) was accepted as a new feature in Python 3.14.
To be honest, I was confused when I heard this news.
There are already many string formatting methods in Python, to name a few:
- C-style formatting with “%” operators: an old-school method
- The
.format()
function: a popular method before f-strings was introduced by Python 3.6 - F-string: a preferred way for many developers due to its convenience and elegance
So why another string formatting syntax?
The Purpose of T-Strings
Simply put, it is to solve the security issues that arise with the f-strings when dealing with in-string expressions.
For example, constructing an SQL query with an f-string as follows is dangerous:
sql = f"SELECT info FROM users WHERE name = '{user}'"