Dot product?

Greg Ewing greg.ewing at compaq.com
Mon Dec 13 05:35:43 EST 1999


"David C. Ullrich" wrote:
> 
> but it doesn't look right -
> seems like the Python way would involve a "for x in X"
> instead of that "for j in range(len(X))".

Sadly, that *is* the current Python idiom for doing parallel
iteration without incurring the overhead of constructing an
intermediate object.

List comprehensions won't change this, unless whatever flavour
of them we get includes a syntax for parallel iteration -- in
which case the normal "for" loop will probably get it as well.

My preferred backward-compatible candidate for this is:

   for x and y in list1, list2:
      ...

Greg



More information about the Python-list mailing list