[Python-Dev] list comprehensions again...

Paul Prescod paul@prescod.net
Tue, 11 Jul 2000 15:49:44 -0500


Paul Prescod wrote:
> 
> ...

> (for x in (0,10,20,30) and y in (0,1,2,3):
>         x+y)
> (0,11,22,33)

Sorry, replace the "and" with ";" or "while" to resolve the ambiguity:

Nested (List):

[for x in (0,10,20,30):
        for y in (0,1,2,3):
                x+y]
[0,11,22,33]


Parallel (Tuple):

(for x in (0,10,20,30) ; y in (0,1,2,3):
        x+y)
(0,11,22,33)


Parallel (Dict):

{for x in (0,10,20,30) ; y in range (0,1,2,3):
        x,y}

-- 
 Paul Prescod - Not encumbered by corporate consensus
Simplicity does not precede complexity, but follows it. 
	- http://www.cs.yale.edu/~perlis-alan/quotes.html