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?

Path csiph.com!usenet.pasdenom.info!news.franciliens.net!news.muarf.org!news.ecp.fr!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'subject:text': 0.05; 'subject:file': 0.07; 'assuming': 0.09; 'lawrence': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'wrote:': 0.18; 'code.': 0.18; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'you?': 0.31; '13,': 0.31; 'subject:other': 0.31; 'url:python': 0.33; 'subject:from': 0.34; 'agree': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'starting': 0.37; 'pm,': 0.38; 'url:mail': 0.40; 'joel': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=zLq0Gjfbo5bS9GB/BeC4qq/s1zpnZuIxMK+ISmNDKN4=; b=SSwfjbkR+sMzonm67ZvrQtLWyQZN/bZcowOj85v00unzPa6U2O8pcfSl/A6iRkRA+Y a2zO0ERhLSpXlDy9AptQbp7cVZbJ5GeZlA7gE06UXoTXRUWCQ+n0dt5zikpbNKwuNDOs OkEyyOWEFeI2GkMCazL+00+GyheWnuydA78kaUATh0CKLBbuLgRVyTpP499ULgH33q/O XL7RKz+U52Kc2Sne7PhbXOy26X/UrEeIISZe37IadukRrjn/rsFkGwPbPSEeGUFWogwr 7LnmGymQi2Lx+Xfg1QWBlMEyH9uKpjwmlmVc9moaaI1h9weMH1kcem8aVXNJWoxvku+i LrMg==
MIME-Version 1.0
X-Received by 10.224.167.208 with SMTP id r16mr768503qay.42.1413225953425; Mon, 13 Oct 2014 11:45:53 -0700 (PDT)
In-Reply-To <m1h4lt$r3k$1@ger.gmane.org>
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 Mon, 13 Oct 2014 14:45:53 -0400
Subject Re: How to select every other line from a text file?
From Joel Goldstick <joel.goldstick@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14830.1413225956.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1413225956 news.xs4all.nl 2842 [2001:888:2000:d::a6]:50846
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:79063

Show key headers only | 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