[Python-ideas] String interpolation for all literal strings
Eric V. Smith
eric at trueblade.com
Fri Aug 7 18:31:31 CEST 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/07/2015 12:18 PM, Barry Warsaw wrote:
> On Aug 07, 2015, at 12:13 PM, Guido van Rossum wrote:
>
>> OK, that sounds reasonable, except that translators need to
>> control substitution order, so s % tuple(...) doesn't work.
>> However, if we use s.format(...) we can use "This interpolates
>> {0} and {1}", and then I'm satisfied. (Further details of the
>> signature of __interpolate__ TBD.)
>
> That doesn't work either, but this does:
>
> "This interpolates {apples} and {oranges}".
I think it would, because you could say this, in some language where
the order had to be reversed:
"This interpolates {1} and {0}"
Now I'll grant you that it reduces usability. But it does provide the
needed functionality.
But I can't see how we'd automatically generate useful names from
expressions, as opposed to just numbering the fields. That is, unless
we go back from general expressions to just identifiers. Or, use
something like Nick's suggestion of also passing in the text of the
expressions, so we could map identifier-only expressions to their
indexes so we could build up yet another string.
Eric.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
iQEcBAEBAgAGBQJVxN1jAAoJENxauZFcKtNxXN0H/iYO8koEg/pqJ9wFQEN/10Sd
Kp9xp0GHj0bHU9uPqzcJEoWPExOpRW5vUqswU+YwtrRg9uuWcvfaASoI1VI1bR29
ABg7R6zYJoxCLluaMo7eHyWQMnbTOAI0Ubm/TNJdvyAcBX+DL5zNNmtXTTr2ti1H
uWo6xfjvGNv4RgGqL96GuPd+KL3ceuWmlapJrVPUT5QA2/nf8qYl9BSvHCY/VxR7
SzGhwOO4yMUOO5VXNLWYZiNvKEFHX9GSHvQcAIqymzY+MDGRt2aIOxz0b9x3jexH
MqbRiVUlzsJObKVjWl2Ejc0yfp3trbYXJasCRMtoyE4VsWc8CNjTncnVgXw/41Q=
=7SDr
-----END PGP SIGNATURE-----
More information about the Python-ideas
mailing list