Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197465
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Thomas Passin <list1@tompassin.net> |
| Newsgroups | comp.lang.python |
| Subject | Re: backslash in triple quoted string |
| Date | Tue, 13 May 2025 09:34:39 -0400 |
| Lines | 72 |
| Message-ID | <mailman.52.1747155796.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> <08f8c6cc-1cb0-4bb1-860f-d9cd56f6a4af@tompassin.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de GGEozRfBymIGHYCTJJEybwy6xFtgHMgaNWYnAh8jZ9JA== |
| Cancel-Lock | sha1:lhnPOOToXbxf+A6llcizSniX/5k= sha256:tsf7HLg+QLSKM9ngsjBz3JDLnLGradBjjFlPk/A5q8w= |
| Return-Path | <list1@tompassin.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| Authentication-Results | mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=tompassin.net header.i=@tompassin.net header.b=W5jeyPAA; dkim-adsp=pass; dkim-atps=neutral |
| X-Spam-Status | OK 0.043 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'this:': 0.03; 'def': 0.04; 'van': 0.07; 'python.': 0.08; 'url:mailman': 0.09; '"""': 0.09; 'though.': 0.09; 'url:reference': 0.09; 'syntax': 0.15; 'url:listinfo': 0.15; '2025': 0.16; 'backslash': 0.16; 'bob': 0.16; 'crashed': 0.16; 'generates': 0.16; 'received:10.0.0': 0.16; 'received:64.90': 0.16; 'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16; 'received:dreamhost.com': 0.16; 'string:': 0.16; 'subject:string': 0.16; 'victor': 0.16; 'wrote:': 0.16; 'python': 0.16; 'instead': 0.17; 'bug': 0.19; 'thu,': 0.19; 'to:addr:python-list': 0.20; 'url-ip:188.166.95.178/32': 0.20; 'url-ip:188.166.95/24': 0.20; 'url-ip:188.166/16': 0.20; 'version': 0.23; 'run': 0.23; 'code': 0.23; 'tried': 0.26; 'example,': 0.28; 'it,': 0.29; 'error': 0.29; 'header:User- Agent:1': 0.30; 'think': 0.30; 'am,': 0.31; 'comment': 0.31; 'program,': 0.31; 'received:100': 0.31; 'program': 0.31; 'python- list': 0.32; 'raw': 0.32; 'received:10.0': 0.32; 'received:mailchannels.net': 0.32; 'received:relay.mailchannels.net': 0.32; 'but': 0.32; 'invalid': 0.35; 'runs': 0.35; 'header:In-Reply-To:1': 0.35; 'also,': 0.36; "it's": 0.36; '>>>': 0.36; 'change': 0.36; 'could': 0.37; 'url- ip:151.101.0.223/32': 0.37; 'url-ip:151.101.128.223/32': 0.37; 'url-ip:151.101.192.223/32': 0.37; 'url-ip:151.101.64.223/32': 0.37; 'example': 0.37; 'url-ip:188/8': 0.38; 'use': 0.39; 'something': 0.39; 'quite': 0.39; 'valid': 0.39; 'appears': 0.40; 'program.': 0.40; 'should': 0.40; 'above': 0.62; 'follow': 0.62; 'skip:b 10': 0.63; 'skip:r 20': 0.64; 'your': 0.64; 'in:': 0.64; 'top': 0.65; 'produce': 0.65; 'well': 0.65; 'canada': 0.67; 'header:Received:6': 0.67; 'received:64': 0.67; 'email:': 0.68; 'right': 0.68; 'der': 0.69; 'drop': 0.69; 'sequence': 0.69; 'raised': 0.70; 'free': 0.71; 'future': 0.72; '....': 0.76; 'supposed': 0.76; 'url:ca': 0.76; 'left': 0.83; '****': 0.84; 'email name:bob': 0.84; 'eventually': 0.84; 'exactly.': 0.84; 'grammar,': 0.84; 'strings': 0.84; 'warning': 0.84; 'british': 0.91; 'url:music': 0.91 |
| X-Sender-Id | dreamhost|x-authsender|tpassin@tompassin.net |
| ARC-Seal | i=1; s=arc-2022; d=mailchannels.net; t=1747143281; a=rsa-sha256; cv=none; b=g4pn2VmL98IPb2S4Du2XUJC7DQAMWCbr/ucJa5oQsB+aktGrMZisQo9MnhIXTZzwHsbBtt XQCUQXLGzKbGN277Mli8JSDdcdzEgQT6icGAJvbRGFXSi/XDfTgVMT5680hNqz1QUJ0BMH FAtVyEoWbF/DEWA9oLLG3w8SO79NAck8lzOHpEkqGh2qPtLVwnsdCYEd3LMQHJyJ6pAtPb jOb2UZAgeLyjai4D5skm71cEpAVdI7mmUgGeXRdTA+JNBqwditqfTjb6Sv2HXcAhbOJhT3 F+zMspjqzxtORywz0VsnOytupHSoYZVUlrJe3UCUnnhuanVTdpFXGjwQfuDwkg== |
| ARC-Message-Signature | i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1747143281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=M0Uq1R/KpiVWb4KtIyt0ztQ2cR+NPeoTsdCmDiz4Svs=; b=Uamzs2LCA9XQBgp5oNds86wRYbxwyFs7JXmvjrLbCQPdur0xcCh6c0uC7AWIYak1Hb3LcH 0wGeohafLTeqVgm+SBA0iHmGkrwplda1IUxI75YLmGgZt93i8J0cx+cDO33u/ousI4KhG1 N+6bn64Jl3pzoUDmGFawCjP8D3v9qpG5v3/ue4rAX96YT+LUxrqTKfRYkhfzZhHnPTkmPT 9X5x1PpZFFGtZpl3RxWb1vn14JT8dVmiumcGdu8S71OziBkaAJHlBXvYZFgw3uD0tl1ZOW iZyLM5bk5PdierweMPB4+XQGhpVkHYQOD3Sh7/ZgUeSI0yDus3K1ggtKNr7ofQ== |
| ARC-Authentication-Results | i=1; rspamd-57f676fcfb-8jqgv; auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net |
| X-Sender-Id | dreamhost|x-authsender|tpassin@tompassin.net |
| X-MC-Relay | Neutral |
| X-MailChannels-SenderId | dreamhost|x-authsender|tpassin@tompassin.net |
| X-MailChannels-Auth-Id | dreamhost |
| X-Inform-Well-Made | 59cf96a01cd4a947_1747143281639_254745009 |
| X-MC-Loop-Signature | 1747143281639:1655585789 |
| X-MC-Ingress-Time | 1747143281639 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net; s=dreamhost; t=1747143281; bh=mfKWsshJlri/5s9UqjlsNKwMnM/T99tavyCpoNHDwzg=; h=Date:From:Subject:To:Content-Type:Content-Transfer-Encoding; b=W5jeyPAACK9GgvutbAGWS6j+MxFpvSGCFFNf/u8p6CsGkJKfv8b1U4BPbsbyK1Eoy WBBeRtKW7sY8Egh0YYjCfeF5i5wsSR6LfrNmGWU9vDbCPvElfM9lz5NrURiFaygrfH auRw0y0t5GWtRfwqz0U57RRRnpmfuEcPgK4YOlgYZq2wOxLbS7cqWXbYZZhsatXCtf EyIoNDMVjDByKh/JX19tRcMJ48CE2fXEKB0JmBP60r0yWAZHsyA3ABY+x1T0yZdia4 x3cu1t0gv/kk+umeWm7BqTFMSDROJblqEwPKLYUOqpxDHZMzL5c8y78ES9z7GdFoy0 wTE8I7FDqjZLg== |
| User-Agent | Mozilla Thunderbird |
| Content-Language | en-US |
| In-Reply-To | <CAJQBtgk7ZoURixi3404asBzJX4X2A5pbCsd6SVWuqbqnMgOgQw@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.39 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <https://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <08f8c6cc-1cb0-4bb1-860f-d9cd56f6a4af@tompassin.net> |
| X-Mailman-Original-References | <CA+HdcZhMPvojVkAnGNy6-qA1Lf8LDG_Wjxef0xfSNQzU=BUEzw@mail.gmail.com> <CAJQBtgmV0+EViR6yWoY22VjHiVZOD6eaPiAhDfUMJRQRj=PfCQ@mail.gmail.com> <CAJQBtgk7ZoURixi3404asBzJX4X2A5pbCsd6SVWuqbqnMgOgQw@mail.gmail.com> |
| Xref | csiph.com comp.lang.python:197465 |
Show key headers only | View raw
On 5/8/2025 2:05 AM, Left Right via Python-list wrote:
> Also, it appears that the change linked above is a lie:
>
> 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.
"Changed in version 3.12: Unrecognized escape sequences produce a
SyntaxWarning. In a future Python version they will be eventually a
SyntaxError."
See https://docs.python.org/3/reference/lexical_analysis.html#strings
Test case for "\" in triple-quoted string:
[code]
>>> def f():
... """\hello"""
<stdin>:2: SyntaxWarning: invalid escape sequence '\h'
... print('hi')
...
>>> f()
hi
[/code]
This example fits the documentation exactly. A SyntaxWarning is emitted
for the unrecognized escape sequence "\h". The program runs as intended.
Please let's drop all the OT back-and-forth.
> On Thu, May 8, 2025 at 7:54 AM Left Right <olegsivokon@gmail.com> wrote:
>>
>> I think it could be this:
>>
>> A backslash-character pair that is not a valid escape sequence now
>> generates a SyntaxWarning, instead of DeprecationWarning. For example,
>> re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an invalid
>> escape sequence, use raw strings for regular expression:
>> re.compile(r"\d+\.\d+")). In a future Python version, SyntaxError will
>> eventually be raised, instead of SyntaxWarning. (Contributed by Victor
>> Stinner in gh-98401.)
>>
>> Found in:
>> https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
>>
>> It's not supposed to crash your program though. If the program crashes
>> because of it, it's a bug in Python.
>>
>> On Thu, May 8, 2025 at 7:00 AM Bob van der Poel via Python-list
>> <python-list@python.org> wrote:
>>>
>>> Did something change in python buggering up my use of a "\ " sequence in a
>>> triple quoted string?
>>>
>>> I have yet to go through my archive on the program, but I tried to run it
>>> today and it crashed quite spectacularly when it hit a """ .... """ line
>>> being used as a comment at the top of a function. I changed the "\" to a
>>> "/" and all is well now.
>>>
>>>
>>> --
>>>
>>> **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars ****
>>> Bob van der Poel ** Wynndel, British Columbia, CANADA **
>>> EMAIL: bob@mellowood.ca
>>> WWW: http://www.mellowood.ca
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next | Find similar
Re: backslash in triple quoted string Thomas Passin <list1@tompassin.net> - 2025-05-13 09:34 -0400
csiph-web