Complex discussions of "simple" problems (was: Loop in a loop?)
Paul Rubin
http
Thu Jan 17 19:57:36 EST 2008
Ben Finney <bignose+hates-spam at benfinney.id.au> writes:
> Enjoyment of the discussion, after all, is the main reward most people
> can ever hope to get for participation in most threads here.
Well then, in that case, what the heck.
from itertools import *
def padzip(*xs, **kw):
pad = kw.get('padding', None)
ts = izip(*[chain(((y,) for y in x), repeat(None)) for x in xs])
def m(t): return tuple((x[0] if x else pad) for x in t)
return imap(m, takewhile(any, ts))
More information about the Python-list
mailing list