3 ms·
Hi! I wrote this. :-) I'm a little late to the conversation (and a bit surprised to see this trending on HN) but am happy to answer any questions; I'll try to
by davepeck 1y ago
Hi! I wrote this. :-)
I'm a little late to the conversation (and a bit surprised to see this trending on HN) but am happy to answer any questions; I'll try to pop in throughout the day.
- 18172828286177 1y agoThis is super cool, thank you.
- maxloh 1y agoHi. I come from a JavaScript background. I am wondering what is the reason behind not using a similar syntax to JavaScript? Seems simpler to me. # Compare this: template = t"<p>{evil}</p>" safe = html(template) # To this: safe = html"<p>{evil}</p>"
- davepeck 1y agoThe PEP originally started with a similar-to-javascript syntax but over time we decided it wasn't the right way to expose these ideas in Python. There's more detail about why this approach was rejected in the PEP: https://peps.python.org/pep-0750/#arbitrary-string-literal-prefixes https://peps.python.org/pep-0750/#arbitrary-string-literal-p...
- varunneal 1y agoWould be interested in inclusion of PEP 292 [1] in your discussion here, which introduced `string.Template`. Is this Template going to be deprecated? [1] https://peps.python.org/pep-0292/ https://peps.python.org/pep-0292/
- davepeck 1y agoPEP 292's `string.Template` will remain; there are no plans to deprecate it. PEP 750's `string.templatelib.Template` is a separate and unrelated type. Amongst many differences, unlike PEP 292, `Template` has a literal form too. I'm hopeful that the confusion will be minimal; in practice, PEP 292 (aka $-strings) is used only in specialized cases, like flufl.i18n, a really deep I18N framework.