mult-indexed xrange?

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Mon Mar 4 20:35:20 EST 2002


On Fri, 1 Mar 2002 13:23:16 -0800, Emile van Sebille <emile at fenx.com> wrote:
>"Huaiyu Zhu" <huaiyu at gauss.almadan.ibm.com> wrote in message
>news:slrna7vqm8.13q.huaiyu at gauss.almadan.ibm.com...
>> The generator facility in 2.2 allows me to do something cool that I
>always
>> wanted: looping around multiple indices with just one for-statement,
>as the
>> following code does.  Is this available with some built-in functions?

I forgot to mention: without generating temporary lists.

>
>for (x,y) in [(i,j) for i in range(2) for j in range(3) ]:
>    print x,y
>0 0 0
>0 0 1
...

Is list comprehension lazy, ie. without generating the actual list?  

Huaiyu



More information about the Python-list mailing list