[Python-checkins] Docs: Update SyntaxError message in REPL example for list comprehension (GH-93901) (GH-94425)

ambv webhook-mailer at python.org
Wed Jun 29 13:22:16 EDT 2022


https://github.com/python/cpython/commit/cbd562ff4e563fa22c784e040f1c97aec21659fa
commit: cbd562ff4e563fa22c784e040f1c97aec21659fa
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2022-06-29T19:22:11+02:00
summary:

Docs: Update SyntaxError message in REPL example for list comprehension (GH-93901) (GH-94425)

(cherry picked from commit 22b783aba05bcc3a21af9e5ae308ffbb98ff6a12)

Co-authored-by: Cheryl Sabella <cheryl.sabella at gmail.com>

files:
M Doc/tutorial/datastructures.rst

diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst
index f847ee325e0d7..f5986fe292fb1 100644
--- a/Doc/tutorial/datastructures.rst
+++ b/Doc/tutorial/datastructures.rst
@@ -268,10 +268,10 @@ it must be parenthesized. ::
    [(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]
    >>> # the tuple must be parenthesized, otherwise an error is raised
    >>> [x, x**2 for x in range(6)]
-     File "<stdin>", line 1, in <module>
+     File "<stdin>", line 1
        [x, x**2 for x in range(6)]
-                  ^
-   SyntaxError: invalid syntax
+        ^^^^^^^
+   SyntaxError: did you forget parentheses around the comprehension target?
    >>> # flatten a list using a listcomp with two 'for'
    >>> vec = [[1,2,3], [4,5,6], [7,8,9]]
    >>> [num for elem in vec for num in elem]



More information about the Python-checkins mailing list