itertools.islice

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

https://www.dropbox.com/s/p7hg7e9qz319v71/findBigWords.py

PS: Enabled use of Nautilus via command line…

I can now open folders with nautilus ~/bin/

itertools.tee


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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: