Find Related products on Amazon

Shop on Amazon

Python’s new t-strings

Published on: 2025-08-16 11:31:35

Template strings, also known as t-strings, have been officially accepted as a feature in Python 3.14, which will ship in late 2025. 🎉 I’m excited; t-strings open the door to safer more flexible string processing in Python. What’s the big idea with t-strings? Since they were introduced in Python 3.6, f-strings have become a very popular way to format strings. They are concise, readable, and powerful. In fact, they’re so delightful that many developers use f-strings for everything… even when they shouldn’t! Alas, f-strings are often dangerously (mis)used to format strings that contain user input. I’ve seen f-strings used for SQL ( f"SELECT * FROM users WHERE name = '{user_name}'" ) and for HTML ( f"
{user_name}
" ). These are not safe! If user_name contains a malicious value, it can lead to SQL injection or cross-site scripting. Template strings are a generalization of Python’s f-strings. Whereas f-strings immediately become a string, t-strings evaluate to a new type, stri ... Read full article.