[ x for x in xrange(10) when p(x) ]
Alex Martelli
aleax at mail.comcast.net
Wed Nov 9 22:27:40 EST 2005
bonono at gmail.com <bonono at gmail.com> wrote:
> Hi,
>
> I am wondering if there is such a thing, as python is moving away from
This becomes a valid list comprehension by writing 'if' instead of
'when'.
> FP functions like dropwhile/takewhile etc.
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.
Alex
More information about the Python-list
mailing list