Michael Spencer <[EMAIL PROTECTED]> writes: > for i in range(10): > result = [] > ...
Do you mean "while True: ..."? > def izip2(*iterables, **kw): > """kw:fill. An element that will pad the shorter iterable""" > fill = repeat(kw.get("fill")) Yet another attempt (untested, uses Python 2.5 conditional expression): from itertools import chain, repeat, dropwhile def izip2(*iterables, **kw): fill = kw.get('fill')) sentinel = object() iterables = [chain(i, repeat(sentinel)) for i in iterables] while True: t = [i.next() for i in iterables] # raise StopIteration immediately if all iterators are now empty dropwhile(lambda v: v is sentinel, t).next() # map all sentinels to the fill value and yield resulting tuple yield tuple([(v if v is not sentinel else fill) for v in t]) -- http://mail.python.org/mailman/listinfo/python-list