[Python-ideas] Draft PEP on string interpolation
Nick Coghlan
ncoghlan at gmail.com
Tue Aug 25 08:35:20 CEST 2015
On 25 August 2015 at 01:03, Paul Moore <p.f.moore at gmail.com> wrote:
> On 24 August 2015 at 13:41, Eric V. Smith <eric at trueblade.com> wrote:
>> On 08/24/2015 07:35 AM, Paul Moore wrote:
>>> I'm once again losing the thread of all the variations being proposed.
>>>
>>> As a reality check, is the expectation that something like the
>>> following will still be possible:
>>>
>>> print(f"Iteration {n}: Duration {end-start} seconds")
>>
>> Yes, that's the PEP 498 proposal. I think (and this is just my opinion)
>> that if we do something more complicated, like the delayed interpolation
>> of i-strings, that we'd still keep f-strings.
>
> OK. That's my point, essentially - the discussion has drifted into
> much more complex areas, with comments about how the wider-ranging
> proposals cover the f-string case as a subset, and I just wanted to be
> sure that there wasn't an implied "so we don't need f-strings any
> more" in there. (Nick at one point spoke quite strongly against adding
> multiple ways of doing the same thing).
That was before my proposed design converged on being a potential
implemention detail of Eric's, though :)
Now we have the option of adding types.InterpolationTemplate as an
implementation detail of f-strings, and then deciding *later* whether
we want to allow creating of interpolation templates with deferred
rendering.
In that regard, Guido suggested that I split PEP 501 into two
different PEPs, one for deferred rendering (which could be done as an
implementation detail of f-strings, with f"templated {text}" being
shorthand for format(i"templated {text}")), and another for
$-substitution over {}-substitution (which would be a competing
proposal for the surface syntax of the substitution expressions). I
think that's a good idea, so I'll do that some time this week (not
sure when, though)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list