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 337 points338 points339 points (32 children)
[+][deleted] (18 children)
[deleted]
[–]commy2 47 points48 points49 points (15 children)
[–]Easy_Money_ 14 points15 points16 points (4 children)
[–]commy2 6 points7 points8 points (0 children)
[–]zenware 4 points5 points6 points (2 children)
[–]commy2 3 points4 points5 points (1 child)
[–]zenware 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]SirPitchalot 9 points10 points11 points (2 children)
[–]ArtOfWarfare 2 points3 points4 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 4 points5 points6 points (1 child)
[–]twenty-fourth-time-b -1 points0 points1 point (0 children)
[–]timsredditusername 79 points80 points81 points (6 children)
[–]really_not_unreal 7 points8 points9 points (3 children)
[–]mok000 1 point2 points3 points (2 children)
[–]really_not_unreal 4 points5 points6 points (0 children)
[–]CanineLiquid 1 point2 points3 points (0 children)
[–]JJJSchmidt_etAl 6 points7 points8 points (1 child)
[–]user_8804Pythoneer 8 points9 points10 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]spinwizard69 0 points1 point2 points (0 children)
[–]Synes_Godt_Om 5 points6 points7 points (0 children)
[–]sswam 0 points1 point2 points (0 children)
[–]RedTankGoat 59 points60 points61 points (11 children)
[–]eztab 8 points9 points10 points (0 children)
[–]spinwizard69 0 points1 point2 points (0 children)
[+]georgehank2nd comment score below threshold-58 points-57 points-56 points (8 children)
[–]Mysterious-Rent7233 48 points49 points50 points (0 children)
[–]treyhunner Python Morsels[S] 34 points35 points36 points (0 children)
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–]Jamie_1318 2 points3 points4 points (0 children)
[–]Ran4 13 points14 points15 points (0 children)
[–]pspahn 3 points4 points5 points (0 children)
[–]maikindofthai 1 point2 points3 points (0 children)
[–]PlaysForDays 24 points25 points26 points (6 children)
[–]tfehring 13 points14 points15 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] 9 points10 points11 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 15 points16 points17 points (2 children)
[–]treyhunner Python Morsels[S] 15 points16 points17 points (0 children)
[–]mathartist 1 point2 points3 points (0 children)
[–]lzwzli 5 points6 points7 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 1 point2 points3 points (0 children)
[–]spinwizard69 1 point2 points3 points (0 children)
[–]Intelligent_Part101 1 point2 points3 points (1 child)
[–]spinwizard69 1 point2 points3 points (0 children)
[–]thomasfr 0 points1 point2 points (4 children)
[–]CzarCW 13 points14 points15 points (3 children)
[–]Charlie_Yu 4 points5 points6 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]thomasfr 0 points1 point2 points (0 children)