Re: Iterate using tuple as index

2005-03-10 Thread Roy Smith
James Stroud <[EMAIL PROTECTED]> wrote: >I would like something more like this: > >for list1_item, list2_item in (some_kind_of_expression): > do_something(list1_item, list2_item) I believe you want: for list1_item, list2_item in zip (list1, list2): blah -- http://mail.python.org/mailman/li

Re: Iterate using tuple as index

2005-03-10 Thread Bengt Richter
On Thu, 10 Mar 2005 13:12:31 -0800, James Stroud <[EMAIL PROTECTED]> wrote: >Hello, > >Its not obvious to me how to do this. I would like to iterate using a tuple as >an index. Say I have two equivalently sized arrays, what I do now seems >inelegant: > >for index, list1_item in enumerate(firstli

Re: Iterate using tuple as index

2005-03-10 Thread James Stroud
Thank you everyone for pointing me to "zip". Very Handy! James -- James Stroud, Ph.D. UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterate using tuple as index

2005-03-10 Thread Tim Jarman
James Stroud wrote: > Hello, > > Its not obvious to me how to do this. I would like to iterate using a > tuple as an index. Say I have two equivalently sized arrays, what I do now > seems inelegant: > > for index, list1_item in enumerate(firstlist): > do_something(list1_item, secondlist[index]

Re: Iterate using tuple as index

2005-03-10 Thread F. Petitjean
Le Thu, 10 Mar 2005 13:12:31 -0800, James Stroud a écrit : > Hello, > > Its not obvious to me how to do this. I would like to iterate using a tuple > as > an index. Say I have two equivalently sized arrays, what I do now seems > inelegant: > > for index, list1_item in enumerate(firstlist): >

Re: Iterate using tuple as index

2005-03-10 Thread Terry Reedy
"James Stroud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Its not obvious to me how to do this. I would like to iterate using a > tuple as > an index. Say I have two equivalently sized arrays, what I do now seems > inelegant: Sounds like you want zip(firstlist, secondlist).

Re: Iterate using tuple as index

2005-03-10 Thread Michael Spencer
James Stroud wrote: Hello, Its not obvious to me how to do this. I would like to iterate using a tuple as an index. Say I have two equivalently sized arrays, what I do now seems inelegant: for index, list1_item in enumerate(firstlist): do_something(list1_item, secondlist[index]) I would like s

Iterate using tuple as index

2005-03-10 Thread James Stroud
Hello, Its not obvious to me how to do this. I would like to iterate using a tuple as an index. Say I have two equivalently sized arrays, what I do now seems inelegant: for index, list1_item in enumerate(firstlist): do_something(list1_item, secondlist[index]) I would like something more like