How is this advantageous over str.format?
How is this advantageous over str.format?
Posted Jan 28, 2025 17:31 UTC (Tue) by NYKevin (subscriber, #129325)In reply to: How is this advantageous over str.format? by siddh
Parent article: A revamped Python string-formatting proposal
> IIUC it is just a locally bound object invalid outside of its scope, like you can't pass it around generically and have the vars substituted without wrapping in a function call which then leads to same thing.
You can indeed pass t-strings around arbitrarily, it's just that the vars are eagerly evaluated at construction time. Which is fine IMHO, because a lazy t-string would just be way too much magic for one bit of syntax (and you can always use a lambda if that's really what you wanted).
