On Tue, Oct 28, 2014 at 12:12 PM, Rustom Mody <rustompm...@gmail.com> wrote: > More generally for d being a 2-D reshape of dd (which may be anything > as long as the size matches) > >>>> dd = [1,2,3,4,5,6,7,8,9,10,11,12] >>>> d=[[dd[i*3+j] for j in range(3)] for i in range(4)] >>>> d > [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
The inner comprehension should surely be a slice: >>> [dd[i*3:i*3+3] for i in range(4)] [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] ChrisA -- https://mail.python.org/mailman/listinfo/python-list