On Nov 28, 2013, at 07:57 PM, anatoly techtonik wrote:
string.Template syntax is ancient (dates back to Python 2.4 from 9 years ago). I haven't seen a template like this for a long time.
string.Template syntax is defined in PEP 292 and was deliberately named "Simpler String Substitutions". The motivation for PEP 292 was the observation of many years of difficulty with translation of gettext message strings in highly i18n'd code. We saw countless errors where translators would leave off a trailing 's' in %(foo)s placeholders, breaking systems, or requiring them to be defensive to the point of being unreadable. $strings have a rich tradition in programming languages and translators seem to have a better time with such placeholders. It's might be useful to provide some flexibility in string.Template, but I don't want to lose the beauty of simplicity or sacrifice the original use case to try to support every possible variation. OTOH, string.Template is just one class in the stdlib. There's no reason other libraries can't provide different classes supporting different formats. FWIW, flufl.i18n builds on string.Template and PEP 292, as well as gettext, to provide a richer API for managing translations in Python programs. Cheers, -Barry