by grifaton · 14y ago · 0 comments
>>> m = [(1,2,3), (4,5,6), (7,8,9)]
>>> zip(*m)
[(1, 4, 7), (2, 5, 8), (3, 6, 9)] >>> m = [(1,2,3), (4,5,6), (7, 8)]
>>> zip(*m)
[(1, 4, 7), (2, 5, 8)] # Wrong
>>> from itertools import izip_longest
>>> list(izip_longest(*m, fillvalue=None))
[(1, 4, 7), (2, 5, 8), (3, 6, None)]