3 ms·
They don't, a string template literal is parsed into a StringTemplate object (including the result of evaluating each template fragment), and interpolate() is a
by masklinn 3y ago
They don't, a string template literal is parsed into a StringTemplate object (including the result of evaluating each template fragment), and interpolate() is a method on that.
- scotty79 3y agoInterpolate method accesses callsite context to extract values of the variables named in template. How?
- masklinn 3y agoI assume it just parses the string templates (at compile-time) and extracts the expressions being templated in, that's not exactly high-flying tech, cpython manages to do it.
- scotty79 3y agoOh, right. The values seem to come from the context of where template was parsed and are kept inside StringTemplate object (.values()).