def __call__(self, x): """Calling a class instance is equivalent to running the processor on the specified sequence `x`.""" result = [] iterator = m.chunks(x, len(x)/10) def get(): try: return iterator.next() except StopIteration: return [] def put(y): result.extend(y) self.process(get, put) return result
def testChunks(self): x = range(10) i = m.chunks(x, 5) x1 = i.next() x2 = i.next() assert(x1 == range(5) and x2 == range(5, 10))