Skip to content

Commit 32886d9

Browse files
methanehugovk
andauthored
Apply suggestions from code review
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 976a5fb commit 32886d9

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

peps/pep-0822.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Example (spaces are visualized as ``_``):
3232
____"""
3333
3434
The closing triple quotes control how much indentation would be removed.
35-
In the above example, the returned string will contain three lines
35+
In the above example, the returned string will contain three lines:
3636

3737
* ``"____<p>\n"`` (four leading spaces)
3838
* ``"______Hello, World!\n"`` (six leading spaces)
@@ -54,7 +54,7 @@ All of these options have drawbacks in terms of code readability and maintainabi
5454
* Left-aligned multiline strings look awkward and tend to be avoided.
5555
In practice, many places including Python's own test code choose other methods.
5656
* Concatenated single-line string literals are more verbose and harder to maintain.
57-
* ``textwrap.dedent()`` is implemented in Python so it require some runtime overhead.
57+
* ``textwrap.dedent()`` is implemented in Python so it requires some runtime overhead.
5858
It cannot be used in hot paths where performance is critical.
5959

6060
This PEP aims to provide a built-in syntax for dedented multiline strings that
@@ -80,7 +80,7 @@ However, this approach has several drawbacks:
8080
they cannot be dedented.
8181
* f-strings may interpolate expressions as multiline string without indent.
8282
In such case, f-string + ``str.dedent()`` cannot dedent the whole string.
83-
* t-strings do not create str objects, so they cannot use the ``str.dedent()`` method.
83+
* t-strings do not create ``str`` objects, so they cannot use the ``str.dedent()`` method.
8484
While adding a ``dedent()`` method to ``string.templatelib.Template`` is an option,
8585
it would lead to inconsistency since t-strings and f-strings are very similar but
8686
would have different behaviors regarding dedentation.
@@ -106,10 +106,10 @@ This newline is not included in the resulting string.
106106

107107
The amount of indentation to be removed is determined by the whitespace
108108
(``' '`` or ``'\t'``) preceding the closing triple quotes.
109-
Mixing spaces and tabs in indentation raises a TabError, similar to Python's
109+
Mixing spaces and tabs in indentation raises a ``TabError``, similar to Python's
110110
own indentation rules.
111111

112-
The dedentation process removes the determined amount of leading whitespace from each line in the string.
112+
The dedentation process removes the determined amount of leading whitespace from every line in the string.
113113
Lines that are shorter than the determined indentation become just an empty line (e.g. ``"\n"``).
114114
Otherwise, if the line does not start with the determined indentation,
115115
Python raises an ``IndentationError``.
@@ -122,7 +122,7 @@ Examples:
122122

123123
.. code-block:: python
124124
125-
# whiltespace is shown as _ and TAB is shown as ---> for clarity.
125+
# Whitespace is shown as _ and tab is shown as ---> for clarity.
126126
# Error messages are just for explanation. Actual messages may differ.
127127
128128
s = d"" # SyntaxError: d-string must be a multiline string
@@ -166,7 +166,7 @@ Examples:
166166
s = d"""
167167
--->--->__Hello
168168
--->--->__World!
169-
--->--->""" # TAB is allowed as indentation.
169+
--->--->""" # Tab is allowed as indentation.
170170
# Spaces are just in the string, not indentation to be removed.
171171
print(repr(s)) # '__Hello\n__World!\n'
172172
@@ -217,10 +217,10 @@ providing a link to the d-string section in the language reference or the releva
217217
Other Languages having Similar Features
218218
========================================
219219

220-
Java 15 introduced a feature called `Text Blocks <https://openjdk.org/jeps/378>`__.
220+
Java 15 introduced a feature called `text blocks <https://openjdk.org/jeps/378>`__.
221221
Since Java had not used triple qutes before, they introduced triple quotes for multiline string literals with automatic indent removal.
222222

223-
C# 11 also introduced a similar feature called `Raw String Literals <https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-11.0/raw-string-literal>`__.
223+
C# 11 also introduced a similar feature called `raw string literals <https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-11.0/raw-string-literal>`__.
224224

225225
`Julia <https://docs.julialang.org/en/v1/manual/strings/#Triple-Quoted-String-Literals>`__ and
226226
`Swift <https://docs.swift.org/swift-book/documentation/the-swift-programming-language/stringsandcharacters/#Multiline-String-Literals>`__
@@ -233,7 +233,7 @@ it removes indent from text too.
233233
Java and Julia uses the least-indented line to determine the amount of indentation to be removed.
234234
Swift, C#, and PHP uses the indentation of the closing triple quotes or closing marker.
235235

236-
This PEP chose the Swift and C# approach because it is more simple and easy to explain.
236+
This PEP chose the Swift and C# approach because it is simpler and easier to explain.
237237

238238

239239
Reference Implementation
@@ -247,7 +247,7 @@ Rejected Ideas
247247
==============
248248

249249
``str.dedent()`` method
250-
------------------------
250+
-----------------------
251251

252252
As mentioned in the Rationale section, this PEP doesn't reject the idea of a ``str.dedent()`` method.
253253
A faster version of ``textwrap.dedent()`` implemented in C would be useful for runtime dedentation.
@@ -259,8 +259,8 @@ However, d-string is more suitable for multiline string literals because:
259259
* It can dedent continuation lines.
260260

261261

262-
triple-backquote
263-
-----------------
262+
Triple-backtick
263+
---------------
264264

265265
It is considered that `using triple backquotes <https://discuss.python.org/t/40679>`__
266266
for dedented multiline strings could be an alternative syntax.
@@ -274,6 +274,7 @@ characters is not seen as a superior idea compared to adding a prefix to string
274274

275275
``__future__`` import
276276
---------------------
277+
277278
Instead of adding a prefix to string literals, the idea of using a ``__future__``
278279
import to change the default behavior of multiline string literals was also considered.
279280
This could help simplify Python's grammar in the future.

0 commit comments

Comments
 (0)