From a062871d0f211b57237f03a38c6464f486b7224b Mon Sep 17 00:00:00 2001 From: James Gerity Date: Sun, 8 Mar 2026 16:20:27 -0400 Subject: [PATCH 1/2] Match tutorial output to real interpreter output --- Doc/tutorial/introduction.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index deabac5253051c..7fea6b89d16b55 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -184,7 +184,8 @@ If you don't want characters prefaced by ``\`` to be interpreted as special characters, you can use *raw strings* by adding an ``r`` before the first quote:: - >>> print('C:\some\name') # here \n means newline! + >>> print('C:\some\name') # here \n means newline, and \s means nothing! + :1: SyntaxWarning: "\s" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\s"? A raw string is also an option. C:\some ame >>> print(r'C:\some\name') # note the r before the quote From 962f60fc3b58981409fc5a61e6a1864fe7a2f651 Mon Sep 17 00:00:00 2001 From: James Gerity Date: Sun, 8 Mar 2026 17:57:25 -0400 Subject: [PATCH 2/2] Avoid invalid escape sequence in example Co-authored-by: Ned Batchelder --- Doc/tutorial/introduction.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 7fea6b89d16b55..7778e37a9adaa9 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -184,12 +184,11 @@ If you don't want characters prefaced by ``\`` to be interpreted as special characters, you can use *raw strings* by adding an ``r`` before the first quote:: - >>> print('C:\some\name') # here \n means newline, and \s means nothing! - :1: SyntaxWarning: "\s" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\s"? A raw string is also an option. - C:\some + >>> print('C:\this\name') # here \t means tab, \n means newline + C: his ame - >>> print(r'C:\some\name') # note the r before the quote - C:\some\name + >>> print(r'C:\this\name') # note the r before the quote + C:\this\name There is one subtle aspect to raw strings: a raw string may not end in an odd number of ``\`` characters; see