Skip to content

gh-80143: Clarify use of backslash in string literals #92398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Doc/reference/lexical_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,10 @@ see section :ref:`encodings`.
In plain English: Both types of literals can be enclosed in matching single quotes
(``'``) or double quotes (``"``). They can also be enclosed in matching groups
of three single or double quotes (these are generally referred to as
*triple-quoted strings*). The backslash (``\``) character is used to escape
characters that otherwise have a special meaning, such as newline, backslash
itself, or the quote character.
*triple-quoted strings*). The backslash (``\``) character is used in
:ref:`escape sequences <escape-sequences>` to denote characters that may not
otherwise appear in the literal, such as quotes, the backslash itself, or newline
characters.

.. index::
single: b'; bytes literal
Expand Down Expand Up @@ -515,6 +516,8 @@ In triple-quoted literals, unescaped newlines and quotes are allowed (and are
retained), except that three unescaped quotes in a row terminate the literal. (A
"quote" is the character used to open the literal, i.e. either ``'`` or ``"``.)

.. _escape-sequences:

.. index:: physical line, escape sequence, Standard C, C
single: \ (backslash); escape sequence
single: \\; escape sequence
Expand Down