[Python-ideas] Let’s make escaping in f-literals impossible

Paul Moore p.f.moore at gmail.com
Sat Aug 20 05:47:10 EDT 2016


On 20 August 2016 at 05:02, Random832 <random832 at fastmail.com> wrote:
> On Fri, Aug 19, 2016, at 19:09, Paul Moore wrote:
>> So, to me
>>
>>  f'{x.partition(' + ')[0]}'
>>
>> reads as a string concatenation. I'm not sure how you'd expect a
>> syntax highlighter to make it look like anything else, to be honest
>
> One possible syntax highlighting scheme:

Thanks for the detailed explanation and example. Yes, that may well be
a reasonable highlighting scheme.

I'd still object to reusing single quotes in the example given,
though, as it would be confusing if printed, or in email, etc. And as
a general principle, "needs syntax highlighting to be readable" is a
problem to me. So I stand by my statement that as a style rule,
f-strings should be written to work identically regardless of whether
this proposal is implemented or not.

Paul


More information about the Python-ideas mailing list