On Mon, Apr 6, 2009 at 8:05 PM, Neal Becker wrote:
> I'm trying to make a multiplexor and demultiplexor, using generators. The
> multiplexor will multiplex N sequences -> 1 sequence (assume equal length).
> The demultiplexor will do the inverse.
>
> The demux has me stumped. The demux should return a tuple of N generators.
from itertools import islice, tee
def demux(iterable, n):
return tuple(islice(it, i, None, n) for (i, it) in
enumerate(tee(iterable, n)))
-Miles
--
http://mail.python.org/mailman/listinfo/python-list