2 ms·
> What do we gain by the shorthand? Because it's new syntax, it allows for parsing the literal ahead of time and eagerly evaluating the substitutions. Code lik
by zahlman 2y ago
> What do we gain by the shorthand?
Because it's new syntax, it allows for parsing the literal ahead of time and eagerly evaluating the substitutions. Code like
bar = 42
spam = t"foo {bar*bar} baz"
essentially gets translated into
bar = 42
spam = Template("foo ", Interpolation(bar*bar), " baz")
That is: subsequent changes to `bar` won't affect the result of evaluating the template, but that evaluation can still apply custom rules.