Re: Iterating two arrays at once

2008-08-29 Thread Bruno Desthuilliers
mathieu a écrit : (snip solution) Thanks all ! FWIW, this has been discussed here *very* recently (a couple hours ago). Look for a thread named "iterating over two arrays in parallel?", and pay special attention to Terry Reedy's answer. -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterating two arrays at once

2008-08-29 Thread mathieu
On Aug 29, 12:46 pm, Matthias Bläsing <[EMAIL PROTECTED] aachen.de> wrote: > Am Fri, 29 Aug 2008 03:35:51 -0700 schrieb mathieu:> > > > A = [1,2,3] > > B = [4,5,6] > > for a,b in A,B: # does not work ! > > print a,b > > > It should print: > > > 1,4 > > 2,5 > > 3,6 > > Hey, > > zip i

Re: Iterating two arrays at once

2008-08-29 Thread Bruno Desthuilliers
mathieu a écrit : Hi there, just trying to figure out how to iterate over two array without computing the len of the array: A = [1,2,3] B = [4,5,6] for a,b in A,B: # does not work ! print a,b It should print: 1,4 2,5 3,6 for a, b in zip(A, B): print a, b or, using ite

Re: Iterating two arrays at once

2008-08-29 Thread Matthias Bläsing
Am Fri, 29 Aug 2008 03:35:51 -0700 schrieb mathieu:> > A = [1,2,3] > B = [4,5,6] > for a,b in A,B: # does not work ! > print a,b > > It should print: > > 1,4 > 2,5 > 3,6 Hey, zip is your friend: for a,b in zip(A,B): print a,b does what you want. If you deal with big l

Iterating two arrays at once

2008-08-29 Thread mathieu
Hi there, just trying to figure out how to iterate over two array without computing the len of the array: A = [1,2,3] B = [4,5,6] for a,b in A,B: # does not work ! print a,b It should print: 1,4 2,5 3,6 Thanks ! -- http://mail.python.org/mailman/listinfo/python-list