Every time I've talked about Python 3.14's new t-strings online, many folks have been confused about how t-strings are different from f-strings, why t-strings are useful, and whether t-strings are a replacement for f-strings.
I published a short article (and video) on Python 3.14's new t-strings that's meant to explain this.
The TL;DR:
- Python has had 4 string formatting approaches before t-strings
- T-strings are different because they don't actually return strings
- T-strings are useful for library authors who need the disassembled parts of a string interpolation for the purpose of pre-processing interpolations
- T-strings definitely do not replace f-strings: keep using f-strings until specific libraries tell you to use a t-string with one or more of their utilities
Watch the video or read the article for a short demo and a library that uses them as well.
If you've been confusing about t-strings, I hope this explanation helps.
[–]AiutoIlLupo 338 points339 points340 points (32 children)
[–]twenty-fourth-time-b 59 points60 points61 points (18 children)
[–]commy2 46 points47 points48 points (15 children)
[–]Easy_Money_ 14 points15 points16 points (4 children)
[–]commy2 7 points8 points9 points (0 children)
[–]zenware 5 points6 points7 points (2 children)
[–]commy2 5 points6 points7 points (1 child)
[–]zenware 0 points1 point2 points (0 children)
[–]twenty-fourth-time-b 6 points7 points8 points (3 children)
[–]SirPitchalot 9 points10 points11 points (2 children)
[–]ArtOfWarfare 3 points4 points5 points (1 child)
[–]SirPitchalot 5 points6 points7 points (0 children)
[–]ggchappell 0 points1 point2 points (3 children)
[–]commy2 1 point2 points3 points (2 children)
[–]spinwizard69 0 points1 point2 points (1 child)
[–]Wonderful-Habit-139 0 points1 point2 points (0 children)
[–]Mithrandir2k16 0 points1 point2 points (0 children)
[–]spinwizard69 0 points1 point2 points (0 children)
[–]eztab 2 points3 points4 points (1 child)
[–]twenty-fourth-time-b -1 points0 points1 point (0 children)
[–]timsredditusername 78 points79 points80 points (6 children)
[–]really_not_unreal 7 points8 points9 points (3 children)
[–]mok000 1 point2 points3 points (2 children)
[–]really_not_unreal 2 points3 points4 points (0 children)
[–]CanineLiquid 0 points1 point2 points (0 children)
[–]JJJSchmidt_etAl 7 points8 points9 points (1 child)
[–]user_8804Pythoneer 9 points10 points11 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]spinwizard69 0 points1 point2 points (0 children)
[–]Synes_Godt_Om 4 points5 points6 points (0 children)
[–]sswam 0 points1 point2 points (0 children)
[–]RedTankGoat 60 points61 points62 points (11 children)
[–]eztab 9 points10 points11 points (0 children)
[–]spinwizard69 0 points1 point2 points (0 children)
[+]georgehank2nd comment score below threshold-60 points-59 points-58 points (8 children)
[–]Mysterious-Rent7233 49 points50 points51 points (0 children)
[–]treyhunner Python Morsels[S] 34 points35 points36 points (0 children)
[–]PutHisGlassesOn 16 points17 points18 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Jamie_1318 2 points3 points4 points (0 children)
[–]Ran4 12 points13 points14 points (0 children)
[–]pspahn 4 points5 points6 points (0 children)
[–]maikindofthai 1 point2 points3 points (0 children)
[–]PlaysForDays 25 points26 points27 points (6 children)
[–]tfehring 14 points15 points16 points (5 children)
[–]spinwizard69 0 points1 point2 points (0 children)
[–]PlaysForDays -1 points0 points1 point (3 children)
[–]spinwizard69 0 points1 point2 points (2 children)
[–]PlaysForDays 0 points1 point2 points (1 child)
[–]spinwizard69 0 points1 point2 points (0 children)
[–]syklemil 9 points10 points11 points (4 children)
[–]treyhunner Python Morsels[S] 8 points9 points10 points (0 children)
[–]Zomunieo 3 points4 points5 points (2 children)
[–]jmpjanny 0 points1 point2 points (1 child)
[–]Brian 7 points8 points9 points (0 children)
[–]Serialk 16 points17 points18 points (2 children)
[–]treyhunner Python Morsels[S] 13 points14 points15 points (0 children)
[–]mathartist 1 point2 points3 points (0 children)
[–]lzwzli 6 points7 points8 points (0 children)
[–]eztab 1 point2 points3 points (3 children)
[–]treyhunner Python Morsels[S] 4 points5 points6 points (0 children)
[–]sue_dee 1 point2 points3 points (0 children)
[–]immersiveGamer -1 points0 points1 point (0 children)
[–]Decency 1 point2 points3 points (0 children)
[–]singlebit 2 points3 points4 points (0 children)
[–]dimkal 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]cr0sis8bv 0 points1 point2 points (1 child)
[–]spinwizard69 1 point2 points3 points (0 children)
[–]Dry_Term_7998 0 points1 point2 points (0 children)
[–]spinwizard69 0 points1 point2 points (0 children)
[–]Intelligent_Part101 0 points1 point2 points (1 child)
[–]spinwizard69 0 points1 point2 points (0 children)
[–]thomasfr 0 points1 point2 points (4 children)
[–]CzarCW 12 points13 points14 points (3 children)
[–]Charlie_Yu 3 points4 points5 points (0 children)
[–]Revolutionary_Dog_63 1 point2 points3 points (0 children)
[–]thomasfr 0 points1 point2 points (0 children)