thebjorn <[EMAIL PROTECTED]> writes:
> Perhaps something like this?
>
> def chop(lst, length):
> from itertools import islice
> it = iter(lst)
> z = [list(islice(it, length)) for i in xrange(1 + len(lst) // length)]
> if len(z) > 1:
> z[-2].extend(z.pop()) # the last item will be empty or contain
> "overflow" elements.
> return z
def chop(lst, length):
def chop1():
t = len(lst) // length - 1
for i in xrange(t):
yield lst[i*length: (i+1)*length]
yield lst[t*length:]
return list(chop1())
--
http://mail.python.org/mailman/listinfo/python-list