[Python-Dev] re: list comprehension / pop quiz
Guido van Rossum
Tue, 11 Jul 2000 13:24:05 -0500
> 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]:
> print x+y
> (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.
Thanks for user testing!
I just wished you had shown it to them with two lists of the same
length. That's the normal case, and I believe that the different
length must have tricked them into believing that it couldn't possibly
I'd like to run the experiment with that change. Do you have another
set of guinea pigs around?
--Guido van Rossum (home page: http://dinsdale.python.org/~guido/)