From 969876e8a7ead9a28b553a9d39e79c2042fde235 Mon Sep 17 00:00:00 2001 From: Moha Dehghan Date: Thu, 29 Oct 2026 12:20:34 +0100 Subject: [PATCH] Doc: Clarify newline escaping in triple-quoted strings (#160886) Clarify that unescaped newlines are preserved in triple-quoted strings and that `"\"` omits them in non-raw string literals. Retain string literal concatenation as an alternative. --- Doc/reference/lexical_analysis.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst index 6f7f352db3c438..4c54b911dfe374 100644 --- a/Doc/reference/lexical_analysis.rst +++ b/Doc/reference/lexical_analysis.rst @@ -676,6 +676,8 @@ sequences, and more details. single: """; string literal single: '''; string literal +.. _triple-quoted-strings: + Triple-quoted strings --------------------- @@ -838,8 +840,10 @@ A backslash can be added at the end of a line to ignore the newline:: ... backslashes or newline characters.' 'This string will not include backslashes or newline characters.' -The same result can be achieved using :ref:`triple-quoted strings `, -or parentheses and :ref:`string literal concatenation `. +The same escape sequence can be used in non-raw +:ref:`triple-quoted strings `. +Alternatively, the same result can be achieved using parentheses and +:ref:`string literal concatenation `. .. _string-escape-escaped-char: