This can be shortened to def interlace(x, i): """interlace(x, i) -> i0, x, i1, x, ..., x, iN """ i = iter(i) i.next() for e in i: yield x yield e
I have noticed a while ago that inside generators StopIteration is automatically trapped, i.e. def g(): yield 1 raise StopIteration yield "Never reached" only yields 1. Not sure if this is documented behavior, however, of if it is an implementation accident. Anybody who knows? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list