On 2025-05-08 08:05:54 +0200, Left Right via Python-list wrote:
> Also, it appears that the change linked above is a lie:

Such strong words ...


> https://docs.python.org/3/reference/lexical_analysis.html#grammar-token-python-grammar-longstringitem
> 
> According to the grammar, any character can follow backslash in a
> valid Python program. The warning / error raised by this code should
> not be a syntax error / warning because the syntax is correct.

Warnings are about technically correct but probably unintended usage.

The documentation you linked to describes (a bit further down) which
escape sequences are recognized and what happens if you use an
unrecognized escape sequence. It also mentions that using an
unrecognized escape sequence *will* be an error in future versions of
Python.

A warning is appropriate here. It gives the programmer a chance to fix
the program now before it breaks.

One could argue that it should say 'unrecognized escape sequence'
instead of 'invalid escape sequence', since it isn't invalid yet, but
that's nitpicking.

        hjp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | h...@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to