]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Docs: Update SyntaxError message in REPL example for list comprehension (GH-93901...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 29 Jun 2022 17:22:22 +0000 (10:22 -0700)
committerGitHub <noreply@github.com>
Wed, 29 Jun 2022 17:22:22 +0000 (19:22 +0200)
(cherry picked from commit 22b783aba05bcc3a21af9e5ae308ffbb98ff6a12)

Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
Doc/tutorial/datastructures.rst

index 927a6722ca2514f9a3e4c09b03d7c9b48ef39ee7..a39dc834001c4c5a388d162376d272efa0a2ce43 100644 (file)
@@ -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]