I just read several tutorials on iteratee, i find that iteratee is similar to python's generator, both allow streamlined data processing. For example, i can implement enumFile and printChunks in python like this:

    EOF = None
    def enum_file(bufsize, filename):
        with open(filename) as input:
            while True:
                data = input.read(bufsize)
                if not data:
                    break
                yield data
        yield EOF

    def print_chunks(print_empty, generator):
        for chunk in generator:
            if chunk==EOF:
                print 'EOF'
                return
            if len(chunk)==0 and not print_empty:
                continue
            print chunk

    print_chunks(True, enum_file(2, "data"))

But i find iteratee far more complicated than python's generator, is that because iteratee can do something python's generator can't, or i simply need to be more familar with functional programming style.



-- 
http://www.yi-programmer.com/blog/