Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Potential Namespace bug for stacked list comprehensions within class definitions #133618

Closed as duplicate of#127542
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@JamesShipley

Description

@JamesShipley

Bug report

Bug description:

I think there is a bug relating to how list comprehensions are evaluated within class definitions on3.11.5:

classC:P= [1,2]Q= []# double `for` loop runs as expectedforiinP:forjinP:Q.append(i*j)# same logic using a list comprehension results in a name error on the inner loopR= [i*jforiinPforjinP# name error here    ]

This may be a duplicate of#127542, however I do not see why it should be seen as expected behaviour - it is slightly bizarre for such a simple list comprehension to be impossible within and only impossible within a class definition? This may be solved byPEP-709, but I am not sure.

CPython versions tested on:

3.11

Operating systems tested on:

No response

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp