Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197444

Re: backslash in triple quoted string

From "Peter J. Holzer" <hjp-python@hjp.at>
Newsgroups comp.lang.python
Subject Re: backslash in triple quoted string
Date 2025-05-11 11:58 +0200
Message-ID <mailman.35.1746958172.3008.python-list@python.org> (permalink)
References <CA+HdcZhMPvojVkAnGNy6-qA1Lf8LDG_Wjxef0xfSNQzU=BUEzw@mail.gmail.com> <CAJQBtgmV0+EViR6yWoY22VjHiVZOD6eaPiAhDfUMJRQRj=PfCQ@mail.gmail.com> <CAJQBtgk7ZoURixi3404asBzJX4X2A5pbCsd6SVWuqbqnMgOgQw@mail.gmail.com> <20250511095858.rwhc7qazptpzntgo@hjp.at>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Back to comp.lang.python | Previous | Next | Find similar


Thread

Re: backslash in triple quoted string "Peter J. Holzer" <hjp-python@hjp.at> - 2025-05-11 11:58 +0200

csiph-web