[Python-Dev] re: list comprehension / pop quiz

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Wed, 12 Jul 2000 02:26:07 +0200 (CEST)


Guido van Rossum wrote:
> 
> What do you think the following code would print?

May I answer this? :-)

> 
>     for i in (10, 20, 30); j in (1, 2, 3):
>         print i+j
> 
> A.
> 
>     11
>     22
>     33
> 
> B.
>     11
>     12
>     13
>     21
>     22
>     23
>     31
>     32
>     33
> 
> I'm afraid the answer will be the same, if these are again numerical
> analysts -- these people live by nested DO loops. :-(

Without being a numerical analyst, I would respond B.
That's what this syntax suggests to me.

Someone proposed `for ... while ...' which clearly suggests something
different than nested loops, and in that case, if I don't know what it
is, I'll read the docs.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252