[Tutor] smarter way of looping
Elderely Geek
epost2 at gmail.com
Thu Jan 26 14:07:50 CET 2006
Hi,
I`m a python newbie and could use some help.
I often do a loop over arbitrary number of sequences. I do it like this:
for elem1 in seq1:
for elem2 in seq2:
do whatever seq1,seq2
this isn`t nice I think. Is there some way I can say
myiterator=geniousfunction(seq1,seq2,seq3)
and then myiterator.next() and have it return the corresponding elemnts
from all sequences like if
seq1 = ['a','b']
seq2 = [1,2]
I could get
a 1
a 2
b 1
b 2
also, how do you loop over all the elements that can be returned by
myiterator?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060126/1db985d6/attachment.htm
More information about the Tutor
mailing list