How to select every other line from a text file?

emile emile at fenx.com
Mon Oct 13 16:01:24 EDT 2014


On 10/13/2014 12:12 PM, Tim Chase wrote:

> You mean like
>
>    offset = 0 # or 1 if you prefer
>    for line in itertools.islice(source_iter, offset, None, 2):
>      do_something(line)


I certainly did.  Learning the python standard library is different from 
learning python and each in its own time.

Emile







More information about the Python-list mailing list