Exemplo n.º 1
0
    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
Exemplo n.º 2
0
 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))