Matteo wrote:

> it works and I like slices, but I was wondering if there was another
> way of doing the same thing, maybe reading the numbers in groups of
> arbitrary length n...

from http://docs.python.org/library/itertools.html#recipes

def grouper(n, iterable, fillvalue=None):
    "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
    args = [iter(iterable)] * n
    return izip_longest(fillvalue=fillvalue, *args)


and it's *damned* fast!


-- 
By ZeD

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to