How to select every other line from a text file?
python.list at tim.thechases.com
Mon Oct 13 21:12:35 CEST 2014
On 2014-10-13 14:45, Joel Goldstick wrote:
> Not apropos to the OP, but what came up in my mind was to write a
> generator function that returns every other line. This would
> separate the reading from the writing code.
You mean like
offset = 0 # or 1 if you prefer
for line in itertools.islice(source_iter, offset, None, 2):
More information about the Python-list