Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 750 -- Template Strings #275

Open
5 of 7 tasks
davepeck opened this issue Feb 3, 2025 · 8 comments
Open
5 of 7 tasks

PEP 750 -- Template Strings #275

davepeck opened this issue Feb 3, 2025 · 8 comments
Labels
PEP Python Enhancement Proposal

Comments

@davepeck
Copy link

davepeck commented Feb 3, 2025

Please consider PEP 750 -- Template Strings
https://peps.python.org/pep-0750/

  • The PEP has been discussed in threads listed in its Post-History header
  • The PEP was announced on Discuss (link in Post-History)
  • The PEP includes all relevant Suggested Sections
  • The PEP includes endorsements from the projects/groups/people it helps
  • The PEP has a CODEOWNERS entry

SIG-specific:

  • Typing PEPs: link to the Typing Council's recommendation for the PEP:
  • Packaging PEPs: don't file the issue here, ask the delegate (Paul Moore) on Packaging Discourse

A few related expressions of support for this PEP:

Alyssa Coughlin: "The proposal in PEP 750 covers the use cases that PEP 501 set out to cover. Where there are differences in the scope and technical details, they are well justified in PEP 750’s favour (hence the withdrawal of PEP 501 during the PEP 750 discussions).”

Phil Jones: "I’d like to express my support as I would like to use template strings to build SQL queries and I’ve recently written SQL-tString in anticipation.”

Nicholas Tollervey: “The capabilities PEP 750 brings would be wonderful for PyScript, and I want to make sure Damien has a heads up so MicroPython and Pyodide have some sort of parity.” (Note: a core PyScript implementer has been working with us on a template language.)

The authors also had meetings with Barry Warsaw (flufl.i18n), David Lord (Jinja), and Andreas Pelme (htpy).

Thanks again for your time & consideration! :-)

@davepeck davepeck added the PEP Python Enhancement Proposal label Feb 3, 2025
@pauleveritt
Copy link

Hi, just checking -- is everything "in order" as far as what we needed to do on this submission?

@gpshead
Copy link
Member

gpshead commented Feb 27, 2025

We haven't gotten to this one yet, it is next up on our schedule for us to discuss internally next week.

@pablogsal
Copy link
Member

We have posted a pre-acceptance message here: https://discuss.python.org/t/pep750-template-strings-new-updates/71594/118

@pablogsal
Copy link
Member

Thank you all for your patience. As discussed, before we can grant final acceptance, we request the following specific changes to the PEP:

1. Clarify Iteration Order for Template Parts

Please enhance the section on __iter__() to more explicitly clarify the order of iteration over the parts of a template string and how this mechanism works. While the current implementation provides a basic description, we'd like to see a more detailed explanation with examples that illustrate how strings and interpolations are interleaved during iteration, especially in edge cases.

2. Add to Rejected Ideas Section

In the "Rejected Ideas" section under "Enable Full Reconstruction of Original Template Literal," please clarify better (with some more examples) that reconstructing the original string is also difficult because the transformation is not 1-to-1 from source to AST. This additional point will help explain why perfect roundtripping is not feasible.

3. Specify Module Location

We've decided that the Template and Interpolation types should be located in a submodule of the string module, specifically as string.templatelib. Please update the PEP to reflect this decision rather than leaving it as TBD.

4. Use Fully Spelled Out Attribute Names

Please rename the abbreviated attributes in the Interpolation class to their fully spelled out versions. Specifically, expr should be renamed to expression and conv should be renamed to conversion.

We believe these changes will improve the clarity and usability of the PEP and its implementation. Once these modifications are made, we will be happy to grant final acceptance.

You can make these changes in parallel to the implementation (so don't wait until the PEP is modified and is officially approved to propose and iterate over the PR). But landing the PR requires the PEP approved.

@davepeck
Copy link
Author

davepeck commented Apr 6, 2025

we request the following specific changes to the PEP

Thanks @pablogsal for the update! And: understood on all changes. I'll make a first pass at all of these this upcoming week and will mention it here on the PR. Exciting!

@lysnikolaou
Copy link
Member

Thanks @pablogsal and SC for the thoughtful feedback.

Please rename the abbreviated attributes in the Interpolation class to their fully spelled out versions. Specifically, expr should be renamed to expression and conv should be renamed to conversion.

Should we also rename format_spec to format_specification or can that stay as-is?

@davepeck
Copy link
Author

davepeck commented Apr 8, 2025

@pablogsal We opened a new PEP 750 PR today. It attempts to address all four requests. Thanks to @AA-Turner for the quick review! We'd love the Steering Council's feedback on it, too. 🎉

(PS: In addition, the pep750 examples repo has been updated to match the latest version of the PEP.)

@pablogsal
Copy link
Member

The Steering Council reviewed today python/peps#4351 and we are happy with the changes so we are formally approving the PEP. Congratulations yet again! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PEP Python Enhancement Proposal
Projects
None yet
Development

No branches or pull requests

5 participants