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

Jay Parlar jparlar at cogeco.ca
Thu Nov 10 01:38:47 EST 2005


On Nov 9, 2005, at 7:30 PM, Alex Martelli wrote:

> No way -- the itertools module is and remains a PRECIOUS resource.  If
> you want an iterator rather than a list, itertools.ifilter is quite
> appropriate here.

Or if you're on 2.4 and want an iterator:

(x for x in xrange(10) if p(x))

Jay P.




More information about the Python-list mailing list