Skip to content

Commit b9c0bcd

Browse files
encukouAA-Turner
andauthored
Apply suggestions from code review
Co-authored-by: Adam Turner <[email protected]>
1 parent 5ecdc81 commit b9c0bcd

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

Doc/reference/expressions.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ Formally:
176176

177177
strings: ( `STRING` | fstring)+ | tstring+
178178

179-
Note that this feature is defined at the syntactical level, so it only works
180-
with literals.
179+
This feature is defined at the syntactical level, so it only works with literals.
181180
To concatenate string expressions at run time, the '+' operator may be used::
182181

183182
>>> greeting = "Hello"
@@ -186,8 +185,9 @@ To concatenate string expressions at run time, the '+' operator may be used::
186185
>>> print(greeting + space + name) # not: print(greeting space name)
187186
Hello Blaise
188187

189-
Also note that literal concatenation can freely mix raw strings,
190-
triple-quoted strings, and formatted string literals. For example::
188+
Literal concatenation can freely mix raw strings, triple-quoted strings,
189+
and formatted string literals.
190+
For example::
191191

192192
>>> "Hello" r', ' f"{name}!"
193193
"Hello, Blaise!"

Doc/reference/lexical_analysis.rst

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ end-of-line sequences:
5353

5454
* the Unix form using ASCII LF (linefeed),
5555
* the Windows form using the ASCII sequence CR LF (return followed by linefeed),
56-
* the old Macintosh form using the ASCII CR (return) character.
56+
* the '`Classic Mac OS`__' form using the ASCII CR (return) character.
57+
58+
__ https://en.wikipedia.org/wiki/Classic_Mac_OS
5759

5860
Regardless of platform, each of these sequences is replaced by a single
5961
ASCII LF (linefeed) character.
@@ -499,7 +501,7 @@ Literals are notations for constant values of some built-in types.
499501
In terms of lexical analysis, Python has :ref:`string, bytes <strings>`
500502
and :ref:`numeric <numbers>` literals.
501503

502-
Other literals are lexically denoted using :ref:`keywords <keywords>`
504+
Other "literals" are lexically denoted using :ref:`keywords <keywords>`
503505
(``None``, ``True``, ``False``) and the special
504506
:ref:`ellipsis token <lexical-ellipsis>` (``...``).
505507

@@ -538,7 +540,7 @@ after the backslash.
538540
For example, ``\"`` denotes the double quote character, and does *not* end
539541
the string:
540542

541-
.. code-block:: python
543+
.. code-block:: pycon
542544
543545
>>> print("Say \"Hello\" to everyone!")
544546
Say "Hello" to everyone!
@@ -613,8 +615,8 @@ The ``r`` prefix can be combined with ``f``, ``t`` or ``b``, so ``fr``,
613615
Formal grammar
614616
--------------
615617

616-
String literals, except :ref:`"F-strings" <f-strings>` and
617-
:ref:`"T-strings" <t-strings>`, are described by the
618+
String literals, except :ref:`"f-strings" <f-strings>` and
619+
:ref:`"t-strings" <t-strings>`, are described by the
618620
following lexical definitions.
619621

620622
These definitions use :ref:`negative lookaheads <lexical-lookaheads>` (``!``)
@@ -791,21 +793,21 @@ Named Unicode character
791793
This sequence cannot appear in :ref:`bytes literals <bytes-literal>`.
792794

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

797799
.. _string-escape-long-hex:
798800

799801
Hexadecimal Unicode characters
800802
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
801803

802-
These sequences :samp:`\\u{xxxx}` and :samp:`\\U{xxxxxxxx}` denote the
803-
Unicode character with the given hex (base 16) value.
804-
Exactly four digits are required for ``\u``; exactly eight digits are
805-
required for ``\U``.
806-
The latter can encode any Unicode character.
804+
These sequences :samp:`\\u{xxxx}` and :samp:`\\U{xxxxxxxx}` denote the
805+
Unicode character with the given hex (base 16) value.
806+
Exactly four digits are required for ``\u``; exactly eight digits are
807+
required for ``\U``.
808+
The latter can encode any Unicode character.
807809

808-
.. code-block:: python
810+
.. code-block:: pycon
809811
810812
>>> '\u1234'
811813
'ሴ'
@@ -856,7 +858,7 @@ They may only contain ASCII characters; bytes with a numeric value of 128
856858
or greater must be expressed with escape sequences (typically
857859
:ref:`string-escape-hex` or :ref:`string-escape-oct`):
858860

859-
.. code-block:: python
861+
.. code-block:: pycon
860862
861863
>>> b'\x89PNG\r\n\x1a\n'
862864
b'\x89PNG\r\n\x1a\n'
@@ -883,7 +885,7 @@ literal characters.
883885
As a result, in raw string literals, :ref:`escape sequences <escape-sequences>`
884886
are not treated specially:
885887

886-
.. code-block:: python
888+
.. code-block:: pycon
887889
888890
>>> r'\d{4}-\d{2}-\d{2}'
889891
'\\d{4}-\\d{2}-\\d{2}'

0 commit comments

Comments
 (0)