def roundrobin(*iterables): "roundrobin('ABC', 'D', 'EF') --> A D E B F C" # Recipe credited to George Sakkis pending = len(iterables) nexts = cycle(iter(it).next for it in iterables) while pending: try: for next in nexts: yield next() except StopIteration: pending -= 1 nexts = cycle(islice(nexts, pending)) _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
I am afraid that in the long layoff in python has meant some new
constructs have passed me by. In googling around I found some nice
little code I want to use, but i don't quite understand it, how it is
called, and what it is an example of. I guess there are generators and
iterators now and it seems this might be an example of one of those
new constructs. Can anyone explain what it is i am looking at, how it
is called, and what it is an example of so that I can look it up:
- [Tutor] What is this an example of (and how can i use it?) kevin parks
- Re: [Tutor] What is this an example of (and how can i us... Kent Johnson
- Re: [Tutor] What is this an example of (and how can i us... Alan Gauld
- Re: [Tutor] What is this an example of (and how can ... kevin parks
- Re: [Tutor] What is this an example of (and how ... Alan Gauld
- Re: [Tutor] What is this an example of (and how ... Kent Johnson
- Re: [Tutor] What is this an example of (and ... kevin parks
- Re: [Tutor] What is this an example of ... Kent Johnson