4 ms·
A revamped Python string-formatting proposal
- lysace 2y agoGut feeling: adds so much more complexity in the core language without a strong enough value prop.
- zahlman 2y agoOn the language side, most of the code is already there to implement f-strings; on the library side, it's two classes that are practically already written in the PEP. The value proposition is that you can use f-string syntax but still defer evaluation like you would with a `.format` call (equivalently: you can prepare templates to format later, without having to repeat the arguments when calling `.format` and without having to re-parse the string for each call). You can also define additional ways to format the string, and thus re-format it multiple different ways. The PEP includes an example of using t-strings (if I might call them that) to do parameterized SQL queries.