35 ms·
It is very cool, but not new. zx does that too. And I did the same thing for MySQL years ago.
by erhaetherth 3y ago
It is very cool, but not new. zx does that too. And I did the same thing for MySQL years ago.
- ptx 3y agoTagged templates[0], the language feature that enables this, were introduced in ECMAScript 2015 apparently – arguably at least somewhat new in the lifespan of JavaScript. :) Java is getting a similar feature with template processors[1], currently in preview. It would be nice to have it in Python as well – i.e. not just f-strings, but something that (like tagged templates) allows a template function process the interpolated values to properly encode them for whatever language is appropriate (e.g. shell, SQL, HTML, etc.). Apparently someone is working on a proposal[2], although there doesn't seem to be much recent progress. [0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [1] https://openjdk.org/jeps/459 https://openjdk.org/jeps/459 [2] https://github.com/jimbaker/tagstr/blob/main/docs/pep.rst https://github.com/jimbaker/tagstr/blob/main/docs/pep.rst