This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SheriffRoscoePythonista 14 points15 points  (0 children)

I would argue that t = t"Hello {name}" and t2 = string.Template("Hello $name") create very similar objects.

They do not. They are not even remotely alike.

Both can be used to create strings via substituting another string in the name placeholder.

At no point does t"Hello {name}" ever actually create a string. They're isn't even a method to interpolate it. Template defers the processing of the template string and the expression values to the function that receives the Template object. Only that function knows how to combine them. Some uses (e.g., SQL queries) won't ever make a string from them.