> unzip doesn't seem to work for me...

It's not a part of the standard Python distribution, but this is a
naive implementation (it doesn't react well to the list's contents
having different lengths).

def unzip(seq):
    result = [[] for i in range(len(seq[0]))]
    for item in seq:
        for index in range(len(item)):
            result[index].append(item[index])
    return result

>>> unzip(zip(range(5), 'abcde'))
[[0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e']]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to