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

Nick Coghlan ncoghlan at gmail.com
Tue Aug 23 08:18:18 EDT 2016


On 21 August 2016 at 03:32, Eric V. Smith <eric at trueblade.com> wrote:
> If anything, I'd make it an error to have any backslashes inside the
> brackets of an f-string for 3.6. We could always remove this restriction at
> a later date.

+1 for this if you can find a way to do it - it eliminates the
problematic cases where the order of evaluation makes a difference,
and ensures the parts within the braces can be reliably processed as
normal Python code.

> In any event, I'll take a look at adding this restriction, just to get an
> estimate of the magnitude of work involved. The easiest thing to do might be
> to disallow backslashes in any part of an f-string for 3.6, although that
> seems to be going too far.

Disallowing \t, \n, etc even in the plain text parts of the f-string
would indeed be problematic.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list