[Python-Dev] list comprehensions again...

Greg Stein gstein@lyra.org
Tue, 11 Jul 2000 16:54:06 -0700

On Tue, Jul 11, 2000 at 07:02:06PM -0400, Barry A. Warsaw wrote:
> >>>>> "TW" == Thomas Wouters <thomas@xs4all.net> writes:
>     TW> I agree that all this together looks dodgy, but I think there
>     TW> is a simple way to view it... I still think
>     TW> 'for x in a; y in b:'
>     TW> is the right syntax for parallel for loops. It's almost "only"
>     TW> syntactic sugar for
>     TW> 'for x,y in map(None, a, b)'
> But wouldn't some variation on
>     for x, y in a, b:
> invoke resonance with the classic idiom?  Okay, now I'm reduced to
> arguing syntax (and syntax which I haven't thought out much :).

for x, y in a, b:

won't work. "a, b" is a tuple constructor. The for-loop will iterate over a
two-item tuple, and unpack each item (a and b) into the x,y variables.

Try again or punt :-)


Greg Stein, http://www.lyra.org/