▲ | cstrahan 9 days ago | |||||||||||||
> It seems like before with an f string we had instant evaluation, now with a t string we control the evaluation You don't completely control the evaluation. From the PEP: > Template strings are evaluated eagerly from left to right, just like f-strings. This means that interpolations are evaluated immediately when the template string is processed, not deferred or wrapped in lambdas. If one of the things you are interpolating is, as a silly example, an invocation of a slow recursive fibonacci function, the template string expression itself (resulting in a Template object) will take a long while to evaluate. | ||||||||||||||
▲ | mortar 8 days ago | parent | next [-] | |||||||||||||
> the template string expression itself (resulting in a Template object) will take a long while to evaluate Are you saying that calling:
Will immediately run the function, as opposed to when the __str__ is called (or is it because of __repr__?) - Apparent I might just have to sit down with the code and grok it that way, but thanks for helping me understand! | ||||||||||||||
| ||||||||||||||
▲ | mortar 8 days ago | parent | prev [-] | |||||||||||||
Awesome, that makes sense now - thanks all! |