PEP750: Template Strings (new updates)

Thanks again for all the feedback and discussion. Based on this conversation, we made the following further updates to the PEP:

  • Template.args is gone; interleaving is no longer discussed
  • Template.strings and .interpolations are the primary tuples
  • Template.__iter__ surfaces str | Interpolation in any order (not necessarily interleaved) and omits empty strings
  • Dropped __eq__ and __hash__
  • Changed templatelib to TBD for now, until a decision can be made
  • Added a note about __repr__

These are merged; you can read PEP 750 here.


There were a couple suggestions about naming in this (and the previous) discussion thread:

  • Consider renaming Interpolation to Field (and .interpolations to .fields)
  • Consider renaming .strings to .literals (with an eye towards future bytes templates)

I don’t feel strongly but if I were forced to bikeshed I might choose “Field” – less typing! – and probably would keep .strings because I’m old and think about byte strings anyway. :slight_smile:

6 Likes