[Python-Dev] RE: list comprehensions (was parsers and compilers for 2.0) (original) (raw)

Greg Ewing greg@cosc.canterbury.ac.nz
Tue, 15 Aug 2000 13:08:00 +1200 (NZST)


> [((a,b)*c, (spam(d)%34)^e) for a in [(x, y) for x in L for y in > S] for b in [b for b in B if mean(b)] for b,c in C for a,d in D > for e in [Egg(a, b, c, d, e) for e in E]]

Note that shadowing of the local variables like that in an LC is NOT allowed, because, like the variables in a normal for loop, they're all at the same scope level.

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 +--------------------------------------+