Guys,

Here is some python code to group in 3's and pad with '',
how would you roll this into kid?

The first 2 function are just general utilities that I use,   The call
statements would be
rolled into kid templates, but I am not sure how?

Thanks
Mike

----------------------------------------------------------------------
#---------------------------------- Start general util funcs
------------------
from itertools import *

def forever(obj):
    while 1:
        yield obj

def take(n, iterable, pad=''):
    retVal = list(islice(iterable, n))
    if (len(retVal) < n):
        padIter = forever(pad)
        retVal = list(chain(retVal, take(n- len(retVal), padIter )))
    return retVal


#------------------- start of code -------------------------

l = [1, 2, 3, 4, 5, 6, 7, 8 ]
my_iter = iter(l)

while(my_iter):
    print take(3, my_iter, '')

Reply via email to