[Python-Dev] re: list comprehension / pop quiz
Tue, 11 Jul 2000 13:09:11 -0400 (EDT)
I sent the message below to the 11 developers here in the office this
morning. They all have 10+ years experience with C, and 2-3 years with
C++, Java, or both. None have used Python (I'm working on it :-), but two
have extensive Perl experience, and one worked on and with functional
languages in grad school. The question was:
OK, folks, language question. Given the statement:
for x in [10, 20, 30]; y in [1, 2]:
(note that the second list is shorter than the first), would you
expect to see:
(A) 'x' and 'y' move forward at the same rate:
(B) 'y' goes through the second list once for each value of 'x':
(C) an error message because the two lists are not the same length?
Votes to me, please.
*Everyone* voted (B). As useful as this capability is, I therefore think
the proposed syntax is likely to mislead.
Hope it's helpful,