[Python-ideas] String interpolation for all literal strings

Paul Moore p.f.moore at gmail.com
Thu Aug 6 17:37:28 CEST 2015


On 6 August 2015 at 12:46, Eric V. Smith <eric at trueblade.com> wrote:
>> TL;DR - Interesting, they started with this syntax:
>>
>>     WriteLine("My name is \{name}");
>>
>> Then moved to this one:
>>
>>     WriteLine($"My name is {name}");
>>
>> I suppose to match C#'s @strings.  I think we're on the right track.
>
> That's very interesting, thanks for the pointers. So they're basically
> doing what we described in the f-string thread, and what my PEP
> currently describes. They do some fancier things with the parser,
> though, relating to strings.
>
> They allow arbitrary expressions, and call expr.ToString with the format
> specifier, the equivalent of us calling expr.__format__. I'll have to
> investigate their usage of IFormattable. Maybe there's
> something we can learn from that.

They also appear to have backed away from allowing interpolation
without an explicit prefix (disclaimer - I didn't read the articles).

Paul


More information about the Python-ideas mailing list