News for hackers. Stuff that matters.
Re:Python's new t-strings by maxloh on Monday April 21, 2025 @01:27PM (#43754336)
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>"
Re:Python's new t-strings by davepeck on Monday April 21, 2025 @01:43PM (#43754479)
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...