3 ms·
I'm excited about this. I really like how JavaScript's tagged template literals https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_liter
by simonw 2y ago
I'm excited about this. I really like how JavaScript's tagged template literals https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... can help handle things like automatic HTML escaping or SQL parameterization, it looks like these will bring the same capability to Python.
- davepeck 2y agoYes! PEP 750 landed exactly there: as a pythonic parallel to JavaScript's tagged template strings. I'm hopeful that the tooling ecosystem will catch up soon so we see syntax coloring, formatting of specific t-string content types, etc. in the future.
- its-summertime 2y agoI just wish it didn't get Pythonified in the process, e.g. needing to be a function call because backtick is hard to type on some keyboards, nearly having a completely separate concept of evaluating the arguments, etc. x`` vs x(t'') is a 2x blowup in terms of line-noise at worst.
- itishappy 2y agoI don't think that's the reason. https://peps.python.org/pep-0750/#arbitrary-string-literal-prefixes https://peps.python.org/pep-0750/#arbitrary-string-literal-p...
- its-summertime 2y agothat gets solved by using a different quoting character for template literals. https://discuss.python.org/t/pep-750-tag-strings-for-writing-domain-specific-languages/60408/57 https://discuss.python.org/t/pep-750-tag-strings-for-writing... > Backticks are traditionally banned from use in future language features, due to the small symbol. No reader should need to distinguish ` from ' at a glance. It’s entirely possible that the prevailing opinion on this has changed, but it’s certainly going to be easier to stick to the letter prefixes and regular quotes. and earlier in the thread the difficulty in typing it for some is cited as another reason
- simonw 2y agoThat's fascinating, TIL backticks are banned from Python.
- BiteCode_dev 2y agoYes, and I hope we will steal obj destructuring soon as well. I mean, they took "yield" and @decorator, we have a trade deficit.