←back to thread

620 points tambourine_man | 2 comments | | HN request time: 0.423s | source
Show context
davepeck ◴[] No.43754220[source]
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.

replies(3): >>43754275 #>>43754336 #>>43754430 #
1. maxloh ◴[] No.43754336[source]
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>"
replies(1): >>43754479 #
2. davepeck ◴[] No.43754479[source]
The 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-p...