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

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Aug 18 20:11:58 EDT 2016


Chris Angelico wrote:

>>>>f"This is a number: {13:0\u07c4}"

If I understand correctly, the proposal intends to make
it easier for a syntax hightlighter to treat

    f"This is a number: {foo[42]:0\u07c4}"

as

    f"This is a number: {    foo[42]     :0\u07c4}"
    ---------------------    -------     ----------
    highlight as string     hightlight   highlight as string
                               as
                              code

I'm not sure an RE-based syntax hightlighter would
have any easier a time with that, because for the
second part it would need to recognise ':' as starting
a string, but only if it followed some stuff that was
preceded by the beginning of an f-string.

I'm not very familiar with syntax higlighters, so I
don't know if they're typically smart enought to cope
with things like that.

-- 
Greg


More information about the Python-ideas mailing list