Introducing t-strings: f-strings with superpowers
summary
Python 3.14 adds t-strings that use f-string syntax but evaluate to a Template instance (string.template) so code can inspect static vs interpolated parts instead of getting a str; that lets libraries escape untrusted SQL/HTML (prevents Bobby Tables style injection), implement grammar-aware rendering (attribute spreading and component calls), and treat format specs/conversions themselves (no TypeError when dunder format rejects a spec). Examples: tdom (pre‑alpha, faster than Django templates but behind Jinja2) and t-sql plus a VS Code tooling demo.
AI-written summary · about
chapters (18)
- 0:00t-strings in Python 3.14
- 2:01What are t-strings
- 3:36t-strings vs f-strings
- 5:54Processing templates
- 7:01Why t-strings needed
- 8:39SQL injection prevention
- 9:50Safe HTML rendering
- 11:27f-strings vs t-strings
- 12:28fstrings.wtf and format specs
- 15:58Custom format specs
- 16:21Chess notation with t-strings
- 18:13Music notation with t-strings
- 20:33TDOM and t-string libraries
- 21:17Girl Scout cookies
- 22:48Building CookieTrails
- 24:29TDOM vs Django templates
- 25:46TDOM performance
- 26:55Reflecting on t-strings
related talks
27m"Disentangling formatted strings with T-strings"
31mPEP 750 - T-strings: safer and smarter string processing
29mUncovering the magic of implementing a new Python syntax feature
24mF Strings!
35mText Is Not Text: The History of Strings in Python
20mPEP 498: The Monologue
28mSecuring Code with the Python Type System
01h 01mF# as a Better Python
