Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79063

Re: How to select every other line from a text file?

References <3be64ca8-d2e7-493a-b4f3-ef114f581450@googlegroups.com> <m1h39u$412$1@reader1.panix.com> <m1h43h$l63$1@ger.gmane.org> <m1h4lt$r3k$1@ger.gmane.org>
Date 2014-10-13 14:45 -0400
Subject Re: How to select every other line from a text file?
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.14830.1413225956.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Oct 13, 2014 at 2:11 PM, emile <emile@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

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to select every other line from a text file? Rff <rwang@avnera.com> - 2014-10-13 10:38 -0700
  Re: How to select every other line from a text file? Chris Angelico <rosuav@gmail.com> - 2014-10-14 04:46 +1100
    Re: How to select every other line from a text file? Grant Edwards <invalid@invalid.invalid> - 2014-10-13 19:04 +0000
  Re: How to select every other line from a text file? John Gordon <gordon@panix.com> - 2014-10-13 17:48 +0000
    Re: How to select every other line from a text file? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-13 19:02 +0100
    Re: How to select every other line from a text file? emile <emile@fenx.com> - 2014-10-13 11:11 -0700
    Re: How to select every other line from a text file? Joel Goldstick <joel.goldstick@gmail.com> - 2014-10-13 14:45 -0400
    Re: How to select every other line from a text file? Tim Chase <python.list@tim.thechases.com> - 2014-10-13 14:12 -0500
    Re: How to select every other line from a text file? emile <emile@fenx.com> - 2014-10-13 13:01 -0700
  Re: How to select every other line from a text file? Gary Herron <gary.herron@islandtraining.com> - 2014-10-13 10:50 -0700
  Re: How to select every other line from a text file? Tim Chase <python.list@tim.thechases.com> - 2014-10-13 12:55 -0500
  Re: How to select every other line from a text file? Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-13 23:54 +0000
  Re: How to select every other line from a text file? Dan Stromberg <drsalists@gmail.com> - 2014-10-13 17:34 -0700

csiph-web