[Python-Dev] PEP-498: Literal String Formatting

Eric V. Smith eric at trueblade.com
Tue Aug 11 17:16:05 CEST 2015


On 08/11/2015 11:09 AM, Alexander Walters wrote:
> This may seam like a simplistic solution to i18n, but why not just add a
> method to string objects (assuming we implement f-strings) that just
> returns the original, unprocessed string.  If the string was not an
> f-string, it just returns self.  The gettext module can be modified, I
> think trivially, to use the method instead of the string directly.

You need the original string, in order to figure out what it translates
to. You need the values to replace into that string, evaluated at
runtime, in the context of where the string appears. And you need to
know where in the original (or translated) string to put them.

The problem is that there's no way to evaluate the values and, before
they're substituted in to the string, use a different template string
with obvious substitution points. This is what PEP 501 is trying to do.

Eric.




More information about the Python-Dev mailing list