-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
Description
Documentation
NOTE: I am filing this issue on behalf of a user question in #python on the Libera IRC network, who was confused about the described discrepancy.
Part of the "Introduction" section of the official tutorial gives a demonstration of printing a Windows path that contains an invalid escape sequence and a newline. As given there, the user is told to expect a session like:
>>> print('C:\some\name') # here \n means newline!
C:\some
ameBut since Python 3.12, the invalid escape sequence \s also produces a SyntaxWarning. In Python 3.14:
>>> print('C:\some\name')
<python-input-0>: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
ameTo avoid confusing beginners, the tutorial should either simplify the path to only include the errant \n, or comment on the existence of the SyntaxWarning and mention that \s is an invalid sequence and is therefore passed through. The latter is probably preferable.
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
Projects
Status
Todo