(no title)
ossopite | 10 months ago
There is an observation that you can use `lambda` inside to delay evaluation of an interpolation, but I think this lambda captures any variables it uses from the context.
ossopite | 10 months ago
There is an observation that you can use `lambda` inside to delay evaluation of an interpolation, but I think this lambda captures any variables it uses from the context.
actinium226|10 months ago
Actually lambda works fine here
notpushkin|10 months ago
Bummer. This could have been so useful:
(Though str.format isn’t really that bad here either.)nhumrich|10 months ago
There are a lot of existing workarounds in the discussions if you are interested enough in using it, such as using lambdas and t-strings together.
LordShredda|10 months ago
o11c|10 months ago
davepeck|10 months ago
That's correct, they don't. Evaluation of t-string expressions is immediate, just like with f-strings.
Since we have the full generality of Python at our disposal, a typical solution is to simply wrap your t-string in a function or a lambda.
(An early version of the PEP had tools for deferred evaluation but these were dropped for being too complex, particularly for a first cut.)
krick|10 months ago
Kinda messy PEP, IMO, I'm less excited by it than I'd like to be. The goal is clear, but the whole design feels backwards.
tylerhou|10 months ago
skeledrew|10 months ago