[Python-ideas] Draft PEP on string interpolation
Nick Coghlan
ncoghlan at gmail.com
Mon Aug 24 03:49:25 CEST 2015
On 24 August 2015 at 11:24, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, Aug 23, 2015 at 08:35:17PM -0400, Eric V. Smith wrote:
>
>> I think the string interpolation object is interesting. It's basically
>> what Petr Viktorin and Chris Angelico discussed and suggested here:
>> https://mail.python.org/pipermail/python-ideas/2015-August/035303.html.
>
> Are you sure that's the right URL? It seems only barely relevant to me.
> It has Chris replying to Petr, but it's a vague suggestion of a "quantum
> string interpolation" (Chris' words) with no details. He asks:
>
> "How hard would this be to implement? Something that isn't a string,
> retains all the necessary information, and then collapses to a string
> when someone looks at it?"
>
> I looked ahead a dozen or two posts, and can't see any further
> discussion. Have I missed something?
That's the level of detail I remembered seeing, and it fairly
concisely describes PEP 501's types.InterpolationTemplate - it's an
object that isn't a string (it's an unrendered template that carries
with it all the information needed to render itself on demand) that
renders itself to a plain string when you look at it with str().
So the answer to Chris's initial "How hard would this be to
implement?" question turned out to be "Not very, once we thought
through the details" :)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list