[ x for x in xrange(10) when p(x) ]

Leif K-Brooks eurleif at ecritters.biz
Thu Nov 10 11:40:21 CET 2005

bonono at gmail.com wrote:
> 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)))

How does a useless generator expression make it more generic?

More information about the Python-list mailing list