[Python-ideas] Draft PEP on string interpolation

MRAB python at mrabarnett.plus.com
Sat Aug 22 01:33:11 CEST 2015


On 2015-08-22 00:21, Mike Miller wrote:
> The more I think about it, trying to push str.format() (or similar) syntax into
> i18n is just too much.  We'll need a different prefix anyway because of the
> compile/runtime differences so why not stick with str.Template formatting?
>
> It fits the use case perfectly, and requires little additional work.
>
> Trying to get consistency with str.format() syntax creates security, policy,
> docs, and tools requirements.  Instead, we could accept a small inconsistency
> (in the grand scheme of things) in order to use the right tool for the job::
>
>       # powerful formatting
>       f'Folder {folder}'
>
>       # simple translation
>       t'Hello $name.'      # or i'', _'', etc
>       dt'Hello             # deferred translation
>
> I'd like to update my draft to reflect this change, unless anyone has objections.
>
f-strings use {} syntax, so I'd prefer t-string to use {} syntax too,
unless you're happy to explain it to all those users who'll be asking
why f-strings use {} but t-strings use $. (I might even be one of them!
:-))



More information about the Python-ideas mailing list