George Sakkis wrote: > >>> list(takewhile(p, xrange(10000000))) > [0, 1] thanks. that is what I am doing now, in a more generic form : takewhile(p, (x for x in xrange(100000000)))