[Python-ideas] extensible template strings
Mike Miller
python-ideas at mgmiller.net
Thu Aug 20 01:14:33 CEST 2015
I also like this feature (of extensible string prefixes) and have encountered it
in my research with Scala, Nim, and to some extent C#. It feels like the right
way to go, and could make a lot of code just "disappear". It's somewhat
analogous to context managers/with statement.
So far I'm calling these "string processors" and wonder how much resistance
there is to the idea. In short it means you would be able to define your own
processors, as Yury mentioned:
f'' ==> Format String
i'' ==> i18n
sql'' ==> Escaped SQL
re'' ==> builds RegEx object
We could include a number of common needs while users could implement those
specific to their applications.
(Should we keep them separate from existing prefixes? I'm not sure about that
part, perhaps we could advise that these new ones to be more than one character
and not be composable.)
Is there interest in this feature?
-Mike
More information about the Python-ideas
mailing list