[Python-Dev] Features for Python 2.0

Jeremy Hylton jeremy@beopen.com
Tue, 25 Jul 2000 12:22:44 -0400 (EDT)


>>>>> "GvR" == Guido van Rossum <guido@beopen.com> writes:

  >> I would also like to volunteer to repeat the "simultaneous loop"
  >> syntax experiment with list comprehensions, i.e. see whether
  >> what's being proposed lines up with people's pre-existing
  >> intuitions.

  GvR> Please do!

  GvR> Though I have no doubt of the outcome:

  GvR>   [x+y for x in [10, 20, 30] for y in [1, 2, 3]]

  GvR> will be almost universally understood to mean

  GvR>   [11, 12, 13, 21, 22, 23, 31, 32, 33].

For reference, here is the what Haskell does with the same definition.

Prelude> [ x+y | x <- [10, 20, 30], y <- [1, 2, 3]]
[11,12,13,21,22,23,31,32,33]

Jeremy

PS I still find the Haskell more readable because it has some simple
syntax that identifies what role each part of the expression plays.
The producer is to the left of the vertical bar and each generator is
identified by a "<-".