
On 6/13/2021 7:24 PM, Chris Angelico wrote:
On Mon, Jun 14, 2021 at 8:58 AM Jim Baker <jim.baker@python.org> wrote:
* Logging strings which don't have to format their expressions - so similar to current logging when not using f-strings, but with the easy interface of f-strings, including desired formatting of expressions in simple logger scenarios
The only benefit would be the string formatting; the expressions have to be evaluated still. Is that worth it?
Personally, I always just log with f-strings and skip the delayed formatting step. I suspect (but have run no benchmarks) that it's faster than delayed formatting, since you skip the whole "parse the string and look for %'s" step. In my case, most of my logging calls actually get logged, anyway.
* Internationalization of strings Of dubious value, since the strings have to be externalized. MAYBE useful but would need something complicated where the original form is a code construct, but the i18n library can get the source code and use it as a lookup key to find the translated form. Seems pretty messy.
I don't think this is of dubious value. It might require some tooling support.
* SQL queries with sanitization of expressions (to avoid "Bobby Tables" injection) You shouldn't be sanitizing your expressions, you should be parameterizing your query. That doesn't mean this is of *no* value, but it does make it look a lot less like a string literal.
Agreed.
* Object literals - something like D"10.2" instead of the somewhat longer D("10.2"), assuming for the latter `from decimal import Decimal as D` (this is a pretty weak argument on the face of it, but I can see the possibility of being more restrictive in the use of monkey patching namespaces with such literals to avoid unnecessary function call overhead...)
Of value only if it gets an extremely compact syntax. Other use-cases could be better served by a syntax like html(i".....") but this one only works if it's that kind of notation.
* Code (or AST) construction, following the quasiquote idea from Lisp Not sure how this would work, but given that I don't use Lisp enough to be familiar with the use-cases, I won't argue this one.
* Latex and other minilanguages (is Latex properly a minilanguage? ;) ) Explain?
I'd love to have some sort of generic interpolation construct, but the use-cases all seem really weak...
Ditto. I do plan to turn my attention to it, however. Eric