Another itertool function?
Steven Taschuk
staschuk at telusplanet.net
Sat Apr 26 15:10:49 EDT 2003
Quoth Magnus Lie Hetland:
[...]
> def weave(*iterables):
> iterables = map(iter, iterables)
> while iterables:
> for it in iterables[:]:
> try:
> yield it.next()
> except StopIteration:
> iterables.remove(it)
>
> Another possible name (which is a bit more unwieldy) would be
> 'roundrobin'. Another one still is iweave (to keep the naming
> convention, even though here there is no clash).
I wrote an equivalent function a while back, too; I called it
"interleave".
(I can't remember what I needed it for, oddly.)
--
Steven Taschuk w_w
staschuk at telusplanet.net ,-= U
1 1
More information about the Python-list
mailing list