[Python-ideas] Draft PEP on string interpolation
Barry Warsaw
barry at python.org
Sat Aug 22 03:38:43 CEST 2015
On Aug 21, 2015, at 04:21 PM, 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.
The main annoyance with string.Template based approaches is the same as
str.format() -- the requirement to use sys._getframe() to access the
interpolation values. I think this was one of the main reasons to propose new
syntax, since the compiler can parse the interpolation string and arrange for
the values to be composed into a substitution dictionary without having to do
ugly locals/globals references. I think this is also Guido's main gripe about
the current function-based implementations.
I still wish we could solve this more limited problem, but I don't see a way
around that without adding syntax, and if you're going to do that, then I
think most people want to go down the whole PEP 498/501 road.
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/20150821/71f36b89/attachment.sig>
More information about the Python-ideas
mailing list