[Python-ideas] String interpolation for all literal strings

Barry Warsaw barry at python.org
Sat Aug 8 00:36:17 CEST 2015


On Aug 07, 2015, at 03:24 PM, Nikolaus Rath wrote:

>On Aug 07 2015, Barry Warsaw <barry-+ZN9ApsXKcEdnm+yROfE0A-XMD5yJDbdMReXY1tMh2IBg at public.gmane.org> wrote:
>> * Literals only
>>
>> I've described elsewhere that accepting non-literals is useful in some
>> cases.
>
>Are you saying you don't want f-strings, but you want something that
>looks like a function (but is actually a special form because it has
>access to the local context)? E.g. f(other_fn()) would perform literal
>interpolation on the result of other_fn()?

Maybe I misunderstood the non-literal discussion.  For translations, you
will usually operate on literal strings, but sometimes you want to operate on
a string via a variable.  E.g.

print(_('These are $apples and $oranges'))

vs.

print(_(as_the_saying_goes))

Nothing magical there.

I guess if we're talking about a string prefix to do all the magic, the latter
doesn't make any sense, except that you couldn't pass an f-string into a
function that did the latter, because you'd want to defer interpolation until
the call site, not at the f-string definition site.  Or maybe the
translateable string comes from a file and isn't ever a literal.  That makes
me think that we have to make sure there's a way to access the interpolation
programmatically.

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150807/deef3443/attachment.sig>


More information about the Python-ideas mailing list