MCPcopy Create free account
hub / github.com/ActiveState/code / roundrobin

Function roundrobin

recipes/Python/528936_Roundrobin_generator/recipe-528936.py:3–11  ·  view source on GitHub ↗
(*iterables)

Source from the content-addressed store, hash-verified

1from itertools import cycle, islice
2
3def roundrobin(*iterables):
4 pending = len(iterables)
5 nexts = cycle(iter(iterable).next for iterable in iterables)
6 while pending:
7 try:
8 for next in nexts: yield next()
9 except StopIteration:
10 pending -= 1
11 nexts = cycle(islice(nexts, pending))

Callers

nothing calls this directly

Calls 1

cycleFunction · 0.85

Tested by

no test coverage detected