How to select every other line from a text file?

Joel Goldstick joel.goldstick at gmail.com
Mon Oct 13 14:45:53 EDT 2014


On Mon, Oct 13, 2014 at 2:11 PM, emile <emile at fenx.com> wrote:
> On 10/13/2014 11:02 AM, Mark Lawrence wrote:
>
>> Why bother to initialise a counter when you can get the enumerate
>> function to do all the work for you?
>
>
> I see it as a question of addressing the audience.
>
> Emile

I don't agree with the idea of using a counter.  Its not pythonic, and
I'm assuming the OP is just starting to learn python.

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.

>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com



More information about the Python-list mailing list