Iterators are very important to Python and their use is found in many programs. The itertools module is provided in the standard library to implement common iterator patterns.
It is written in the C language and hence is the most optimised iterator module out there.
islice can be used to extract data from a particular point in a data stream (like text from the Standard Input). It returns an iterator that works with a sub-group of a sequence.
Its syntax can be looked up with
$ pydoc itertools.islice
PS: Enabled use of Nautilus via command line…
I can now open folders with nautilus ~/bin/
Using tee we can run several iterators over a sequence. tee returns more than 1 iterables to be used.
itertools.tee(sequence,n) where sequence is to be iterated over. n is the number of iterables to be created by tee.