def list_to_chunks(l, n):
    'Yield successive n-sized chunk lists from l.'
    for i in xrange(0, len(l), n):
        (yield l[i:(i + n)])
Yield successive n-sized chunk lists from l.
def list_to_chunks(l, n):
    
    for i in xrange(0, len(l), n):
        (yield l[i:(i + n)])