PEP 750: Tag Strings For Writing Domain-Specific Languages

Thanks for the PEP! I’m excited to see and use what comes out the other end!

The two thoughts I had:

  1. This means we’ll never get another string prefix again (in reality). It also means people are likely going to use other single letters prefixes at some point (which as someone else points out, probably hurts discoverability). So I think it deserves at least a section on the rejected alternatives as to not something more obviously different (greet!"foo" or back ticks as strawmen)

  2. The title of the PEP mentions this is for DSLs, however one reason to desire this feature has nothing to do with runtime semantics: annotating what the string is to tools. E.g. py"""...""" without any runtime implication is still useful as editors can syntax highlight and formatters/linters can format/lint. Same for sql"""...""" etc…
    So, I’d love to see that get some attention (which could be as much as a new stdlib module which has a __getattr__ for any name that just returns a function that is mostly just string identity (strawman on whether it acts like bare string or f string). Or as little as mentioning this is a use case which can be explored in another PEP, and that this PEP adds the obvious groundwork, and otherwise doesn’t block future improvements)

17 Likes