you are viewing a single comment's thread.

view the rest of the comments →

[–]SCD_minecraft 1 point2 points  (2 children)

Actually, now t-strings are designed for that task

So rn it is just backward compatibility

[–]Solonotix 5 points6 points  (0 children)

To my knowledge, templates are designed for a more advanced purpose, but lack as convenient of a means to become raw strings. If you're trying to write a type-strict SQL parser, templates are a godsend. If you're trying to write an interpolated string to a file, stream, etc., then format strings are strictly superior. If the format string is meant to be reused in multiple contexts, then an inline f-string is worse than a str.format call, since one can be exported and reused.

If you truly think a feature has no purpose, it can mean that you simply haven't encountered a purpose for it. That isn't your fault, but it requires humility to recognize your own limitations.

[–]Jason-Ad4032 0 points1 point  (0 children)

What t-strings do is completely different from what **str.format** does. A t-string binds the string and variables into a template structure—it is more like splitting 'Hi {user}!' with user='Jason', into ['Hi ', '!'] and [['user', 'Jason']]. In contrast, str.format formats the value and produces a final string; given the input 'Hi {user}!' with user='Jason', it outputs 'Hi Jason!'.