PEP 750: Template Strings proposes a new addition to the Python programming language that generalizes f-strings. Unlike f-strings, t-strings evaluate to a new type, Template
, that provides access to the string and its interpolated values before they are combined:
name = "World"
template: Template = t"Hello {name}"
assert template.args[0] == "Hello "
assert template.args[1].value == "World"
This opens the door to a variety of new use cases. The proposal is currently in the draft stage and open for feedback.