Skip to content

inconsistent behavior of tuple without parenthesis between tuple and list comprehensions and for statement #102771

Open
@luoxzhg

Description

@luoxzhg

Bug report

tuple without parenthesis in for statement is allowed

for i in 1,2,3: print(i)

output

1
2

but in list comprehensions, it is SyntaxError

[i for i in 1,2,3]

output

  File "<stdin>", line 1
    [i for i in 1, 2, 3]
                 ^
SyntaxError: invalid syntax

tuple comprehensions is same as this.

Your environment

  • CPython versions tested on: '3.11.2 (main, Feb 16 2023, 03:15:23) [Clang 14.0.0 (clang-1400.0.29.202)]'
  • Operating system and architecture:macos 12.6.3 x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions