fast sub list operations
Skip Montanaro
skip at pobox.com
Tue Oct 16 10:37:13 EDT 2001
>> >>> zip([1,2,3],[7,8,9])
>> [(1, 7), (2, 8), (3, 9)]
Robin> I know about NumPy and like it a lot, but it's a bit heavyweight
Robin> for what we need. I also know about zip and apart from there
Robin> being no unzip it doesn't join up my list which should look like
Robin> [1,7,2,8,3,9].
Whoops... Try this instead:
>>> l = zip([1,2,3],[7,8,9])
>>> reduce(operator.add, l, ())
(1, 7, 2, 8, 3, 9)
Obviously, if you need a list, you can apply that function to the result.
--
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/
More information about the Python-list
mailing list