3 ms·
Hi. 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 t
by maxloh 2y ago
Hi. 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 2y 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...