[Python-Dev] list comprehensions again...

Greg Wilson gvwilson@nevex.com
Tue, 11 Jul 2000 23:33:51 -0400 (EDT)

> Thomas Wouters wrote:
> I still think
> 'for x in a; y in b:' 
> is the right syntax for parallel for loops. It's almost "only"
> syntactic sugar for
> 'for x,y in map(None, a, b)'
> but it's fairly straightforward, and in large blocks of code it might
> look a lot better.

Is there a built-in function in Python to combine sequences elementwise?
If I can write:

for x,y in pairwise(a, b):

and if the compiler is smart enough to avoid actually constructing the
pairwise list, then perhaps new syntax is unnecessary?

> Given that you can already do the nested-for-loop with a nested for
> loop, and it doesn't suffer (much) in way of readability or pythonity,
> I think most people will realize that the parallel for loop does
> actually do a parallel for-each.

I disagree.  That doesn't mean people can't be taught/won't remember that
multi-loops are executed in step, rather that by cross product, but I
believe most people will guess wrong the first time they see the current