In a sense, the main innovation you've come up with here is to delay evaluation of the expressions until explicitly requested. Where PEP 501 evaluates the interpolations eagerly, your proposal uses lambdas instead, which honor the scope rules (except for walrus operators) but supports the use case of passing one of these to logging functions (which may or may not request evaluation).
Thinking of the translation use case, it would be nice if we could decouple calling those lambdas from constructing a string by combining them with the fixed portions of the template -- my current translation example throws away the return value of calling the object, instead saving the results from the lambdas for later use with the .format() method.
We should think of some basic APIs to call the lambdas and to access the other information (fixed string parts and format specs -- and what to do if there are interpolations in a format spec) and then design some higher level APIs (e.g. __str__).
Because the major functionality seems to be about lambdas, how about we call these l-strings? (And yes, we should still have a subclass t-strings with a customizable API for translations.)
In a sense, the main innovation you've come up with here is to delay evaluation of the expressions until explicitly requested. Where PEP 501 evaluates the interpolations eagerly, your proposal uses lambdas instead, which honor the scope rules (except for walrus operators) but supports the use case of passing one of these to logging functions (which may or may not request evaluation).
Thinking of the translation use case, it would be nice if we could decouple calling those lambdas from constructing a string by combining them with the fixed portions of the template -- my current translation example throws away the return value of calling the object, instead saving the results from the lambdas for later use with the .format() method.
We should think of some basic APIs to call the lambdas and to access the other information (fixed string parts and format specs -- and what to do if there are interpolations in a format spec) and then design some higher level APIs (e.g.
__str__
).Because the major functionality seems to be about lambdas, how about we call these l-strings? (And yes, we should still have a subclass t-strings with a customizable API for translations.)