parywu@seed.net.tw: > [x for x in [1, 2, 3], y for y in [4, 5, 6]] > and the result surprised me, that is: > [[1,2,3],[1,2,3],[1,2,3],9,9,9] Did you by any chance execute that in an environment where y was previously bound to 9? It will be parsed as [x for x in ([1, 2, 3], y) for y in [4, 5, 6]] which should give a NameError if y is previously unbound, since it will try to evaluate ([1, 2, 3], y) before y is bound by the inner loop. But executing y = 9 beforehand will give the results you got. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4