Message190420
This code:
class Sudoku(dict):
COLUMNS = [
{(x, y) for y in xrange(9)} for x in xrange(9)
]
When run on Python 2.7.5, fails with this traceback:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
class Sudoku(object):
File "<pyshell#3>", line 3, in Sudoku
{(x, y) for y in xrange(9)} for x in xrange(9)
File "<pyshell#3>", line 3, in <setcomp>
{(x, y) for y in xrange(9)} for x in xrange(9)
NameError: global name 'x' is not defined
Yet `x` is clearly not a global - it's defined in the comprehension.
Running the comprehension outside of the class gives no error:
>>> [
{(x, y) for y in xrange(9)} for x in xrange(9)
]
[set([...]), ...]
Nor does using `set`:
class Sudoku(dict):
COLUMNS = [
set((x, y) for y in xrange(9)) for x in xrange(9)
] |
|
Date |
User |
Action |
Args |
2013-05-31 22:22:08 | Eric.Wieser | set | recipients:
+ Eric.Wieser |
2013-05-31 22:22:08 | Eric.Wieser | set | messageid: <1370038928.9.0.337300237862.issue18110@psf.upfronthosting.co.za> |
2013-05-31 22:22:08 | Eric.Wieser | link | issue18110 messages |
2013-05-31 22:22:08 | Eric.Wieser | create | |
|