Python 3.14 T-Strings: Safer SQL, HTML, and AI Prompts
Python 3.14.6 shipped June 10 with 179 bugfixes, but the t-strings feature introduced in October 2025 now has its first major library adopter: SQLAlchemy 2.1 added native t-string support in January, enabling safer SQL, HTML, and AI prompts by separating template literals from interpolated values for inspection and escaping.
Python 3.14.6 shipped June 10 — 179 bugfixes, mostly noise. But buried in the release is a signal worth paying attention to: the t-strings feature introduced in October 2025 now has its first major library adopter. SQLAlchemy 2.1 https://www.sqlalchemy.org/blog/2026/01/21/sqlalchemy-2.1.0b1-released/ added native t-string support in January. That changes the calculus for developers who dismissed t-strings as interesting-but-not-yet-useful. What T-Strings Actually Are Not What You Think The most common misconception: t-strings are “lazy f-strings” that defer evaluation. They’re not. When you write t"Hello, {name} " , the expression name evaluates immediately — just like with an f-string. What’s different is the result. An f-string hands you a finished str . A t-string hands you a Template object from string.templatelib https://docs.python.org/3/library/string.templatelib.html , with the literal text fragments and the evaluated values kept in separate buckets: name = "Alice" f-string: done, combined, unrecoverable result f = f"Hello, {name} " print result f "Hello, Alice " — it's already a string t-string: Template object, parts still separated result t = t"Hello, {name} " print result t.strings 'Hello, ', ' ' print result t.interpolations 0 .value 'Alice' That separation is the point. Before the parts get combined into a final string, a library — or your own processor function — can inspect, validate, escape, or transform the interpolated values. Once an f-string fires, that opportunity is gone. Use Case 1: HTML and XSS Prevention XSS bugs often look safe at a glance. An f-string inside a template feels fine until a user submits