Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
Closed as duplicate of#127542
Closed as duplicate of#127542
Description
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