islice ==> [::]

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Mar 7 07:49:19 EST 2008


I find itertools.islice() useful, so for Python 3.x I may like to see
it removed from the itertools module, and the normal slicing syntax
[::] extended to work with generators/iterators too.

from itertools import islice
primes = (x for x in xrange(1,999) if all(x % y for y in xrange(2,
x)))
print list(islice(primes, 0, 20))
==>
print list(primes[:20])

Bye,
bearophile



More information about the Python-list mailing list