Skip to content

Commit cdb9d59

Browse files
committed
Address review
1 parent b9c0bcd commit cdb9d59

File tree

2 files changed

+60
-60
lines changed

2 files changed

+60
-60
lines changed

Doc/reference/expressions.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,6 @@ For example::
192192
>>> "Hello" r', ' f"{name}!"
193193
"Hello, Blaise!"
194194

195-
However, bytes literals may only be combined with other byte literals;
196-
not with string literals of any kind.
197-
Also, template string literals may only be combined with other template
198-
string literals::
199-
200-
>>> t"Hello" t"{name}!"
201-
Template(strings=('Hello', '!'), interpolations=(...))
202-
203195
This feature can be used to reduce the number of backslashes
204196
needed, to split long strings conveniently across long lines, or even to add
205197
comments to parts of strings. For example::
@@ -208,6 +200,14 @@ comments to parts of strings. For example::
208200
"[A-Za-z0-9_]*" # letter, digit or underscore
209201
)
210202

203+
However, bytes literals may only be combined with other byte literals;
204+
not with string literals of any kind.
205+
Also, template string literals may only be combined with other template
206+
string literals::
207+
208+
>>> t"Hello" t"{name}!"
209+
Template(strings=('Hello', '!'), interpolations=(...))
210+
211211

212212
.. _parenthesized:
213213

Doc/reference/lexical_analysis.rst

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -709,92 +709,92 @@ Standard C. The recognized escape sequences are:
709709
Ignored end of line
710710
^^^^^^^^^^^^^^^^^^^
711711

712-
A backslash can be added at the end of a line to ignore the newline::
712+
A backslash can be added at the end of a line to ignore the newline::
713713

714-
>>> 'This string will not include \
715-
... backslashes or newline characters.'
716-
'This string will not include backslashes or newline characters.'
714+
>>> 'This string will not include \
715+
... backslashes or newline characters.'
716+
'This string will not include backslashes or newline characters.'
717717

718-
The same result can be achieved using :ref:`triple-quoted strings <strings>`,
719-
or parentheses and :ref:`string literal concatenation <string-concatenation>`.
718+
The same result can be achieved using :ref:`triple-quoted strings <strings>`,
719+
or parentheses and :ref:`string literal concatenation <string-concatenation>`.
720720

721721
.. _string-escape-escaped-char:
722722

723723
Escaped characters
724724
^^^^^^^^^^^^^^^^^^
725725

726-
To include a backslash in a non-:ref:`raw <raw-strings>` Python string
727-
literal, it must be doubled. The ``\\`` escape sequence denotes a single
728-
backslash character::
726+
To include a backslash in a non-:ref:`raw <raw-strings>` Python string
727+
literal, it must be doubled. The ``\\`` escape sequence denotes a single
728+
backslash character::
729729

730-
>>> print('C:\\Program Files')
731-
C:\Program Files
730+
>>> print('C:\\Program Files')
731+
C:\Program Files
732732

733-
Similarly, the ``\'`` and ``\"`` sequences denote the single and double
734-
quote character, respectively::
733+
Similarly, the ``\'`` and ``\"`` sequences denote the single and double
734+
quote character, respectively::
735735

736-
>>> print('\' and \"')
737-
' and "
736+
>>> print('\' and \"')
737+
' and "
738738

739739
.. _string-escape-oct:
740740

741741
Octal character
742742
^^^^^^^^^^^^^^^
743743

744-
The sequence :samp:`\\\\{ooo}` denotes a *character* with the octal (base 8)
745-
value *ooo*::
744+
The sequence :samp:`\\\\{ooo}` denotes a *character* with the octal (base 8)
745+
value *ooo*::
746746

747-
>>> '\120'
748-
'P'
747+
>>> '\120'
748+
'P'
749749

750-
Up to three octal digits (0 through 7) are accepted.
750+
Up to three octal digits (0 through 7) are accepted.
751751

752-
In a bytes literal, *character* means a *byte* with the given value.
753-
In a string literal, it means a Unicode character with the given value.
752+
In a bytes literal, *character* means a *byte* with the given value.
753+
In a string literal, it means a Unicode character with the given value.
754754

755-
.. versionchanged:: 3.11
756-
Octal escapes with value larger than ``0o377`` (255) produce a
757-
:exc:`DeprecationWarning`.
755+
.. versionchanged:: 3.11
756+
Octal escapes with value larger than ``0o377`` (255) produce a
757+
:exc:`DeprecationWarning`.
758758

759-
.. versionchanged:: 3.12
760-
Octal escapes with value larger than ``0o377`` (255) produce a
761-
:exc:`SyntaxWarning`.
762-
In a future Python version they will raise a :exc:`SyntaxError`.
759+
.. versionchanged:: 3.12
760+
Octal escapes with value larger than ``0o377`` (255) produce a
761+
:exc:`SyntaxWarning`.
762+
In a future Python version they will raise a :exc:`SyntaxError`.
763763

764764
.. _string-escape-hex:
765765

766766
Hexadecimal character
767767
^^^^^^^^^^^^^^^^^^^^^
768768

769-
The sequence :samp:`\\x{hh}` denotes a *character* with the hex (base 16)
770-
value *hh*::
769+
The sequence :samp:`\\x{hh}` denotes a *character* with the hex (base 16)
770+
value *hh*::
771771

772-
>>> '\x50'
773-
'P'
772+
>>> '\x50'
773+
'P'
774774

775-
Unlike in Standard C, exactly two hex digits are required.
775+
Unlike in Standard C, exactly two hex digits are required.
776776

777-
In a bytes literal, *character* means a *byte* with the given value.
778-
In a string literal, it means a Unicode character with the given value.
777+
In a bytes literal, *character* means a *byte* with the given value.
778+
In a string literal, it means a Unicode character with the given value.
779779

780780
.. _string-escape-named:
781781

782782
Named Unicode character
783783
^^^^^^^^^^^^^^^^^^^^^^^
784784

785-
The sequence :samp:`\\N\\{{name}\\}` denotes a Unicode character
786-
with the given *name*::
785+
The sequence :samp:`\\N\\{{name}\\}` denotes a Unicode character
786+
with the given *name*::
787787

788-
>>> '\N{LATIN CAPITAL LETTER P}'
789-
'P'
790-
>>> '\N{SNAKE}'
791-
'🐍'
788+
>>> '\N{LATIN CAPITAL LETTER P}'
789+
'P'
790+
>>> '\N{SNAKE}'
791+
'🐍'
792792

793-
This sequence cannot appear in :ref:`bytes literals <bytes-literal>`.
793+
This sequence cannot appear in :ref:`bytes literals <bytes-literal>`.
794794

795-
.. versionchanged:: 3.3
796-
Support for `name aliases <https://www.unicode.org/Public/16.0.0/ucd/NameAliases.txt>`__
797-
has been added.
795+
.. versionchanged:: 3.3
796+
Support for `name aliases <https://www.unicode.org/Public/16.0.0/ucd/NameAliases.txt>`__
797+
has been added.
798798

799799
.. _string-escape-long-hex:
800800

@@ -807,14 +807,14 @@ Exactly four digits are required for ``\u``; exactly eight digits are
807807
required for ``\U``.
808808
The latter can encode any Unicode character.
809809

810-
.. code-block:: pycon
810+
.. code-block:: pycon
811811
812-
>>> '\u1234'
813-
'ሴ'
814-
>>> '\U0001f40d'
815-
'🐍'
812+
>>> '\u1234'
813+
'ሴ'
814+
>>> '\U0001f40d'
815+
'🐍'
816816
817-
These sequences cannot appear in :ref:`bytes literals <bytes-literal>`.
817+
These sequences cannot appear in :ref:`bytes literals <bytes-literal>`.
818818

819819

820820
.. index:: unrecognized escape sequence

0 commit comments

Comments
 (0)