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


Groups > comp.lang.python > #43974

Re: There must be a better way

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'welcome.': 0.07; 'cc:addr:python-list': 0.11; 'python': 0.11; '2.7': 0.14; 'changes': 0.15; 'csv': 0.16; 'instead:': 0.16; 'subject:There': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'williams': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'run': 0.32; 'url:python': 0.33; 'received:google.com': 0.35; 'version': 0.36; 'next': 0.36; 'method': 0.36; 'shows': 0.36; 'url:org': 0.36; 'url:library': 0.38; 'pm,': 0.38; 'either': 0.39; 'skip:n 10': 0.64; '20,': 0.68; 'sender:addr:chris': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=go5S0KbS7vU3+I2dQbFReEkanAYBQl+UVu4wwVtqwt4=; b=Zzwn8+XLjJ8J+vleoaohb82soKnS5EccNp0rjQ46GODjYWTBT1Hgd0nAqvVdZJl/VZ 3d0Xm+75JTZAXorbgiYTfCbBHkqCBgq5Ewp04xLW0VOlwBDajwQYGhYWhlETki+Jzl5f keS9TAYeu9/zNEsCV7iBVmTR9V4YuuF7FGd1Y=
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=go5S0KbS7vU3+I2dQbFReEkanAYBQl+UVu4wwVtqwt4=; b=iqTeloUbqPkQRXGzzlqClpB00qcby+dx1hyK0MqK6A8Abp7IovSiV2c+KFP8PVm45g vdlV98bhgm7GZqPhQ4geTumbmsjKNfAJ86sl05RzwDtHCF3acr+Do0hWYs8BHOk/xmc1 Pv7wDNzESswedh+6gdn1uLggqIhnXIlXPv/rhe+QqK1OTo6QQ+OxWKnAEk7WdElvpPPY c7rBdO4ONleI4mNVJ0zpT2604yIdtvW+LgfOW/A9QAAjRbLR/29c0GPWcv2uwHK4tiMo 1vLtJ/bUCoGDG69jtRnEK05mHw0tBTySDEJXQQ2peyQJoeZkJF5sJ18r/AaEKqnRaer8 iDww==
MIME-Version 1.0
X-Received by 10.50.164.162 with SMTP id yr2mr4900369igb.0.1366502225966; Sat, 20 Apr 2013 16:57:05 -0700 (PDT)
Sender chris@rebertia.com
In-Reply-To <kkv9bt$9bm$1@theodyn.ncf.ca>
References <kkv9bt$9bm$1@theodyn.ncf.ca>
Date Sat, 20 Apr 2013 16:57:05 -0700
X-Google-Sender-Auth nItLyA9jPYuIttDlPPoglAkBMeM
Subject Re: There must be a better way
From Chris Rebert <clp2@rebertia.com>
To "Colin J. Williams" <cjw@ncf.ca>
Content-Type text/plain; charset=UTF-8
X-Gm-Message-State ALoCoQkOOPpNMIIHj5alVyV+okOk6Ks2fdSBuOv3bZ7YMtJ7czmN72cVXZETjOvDm/05jZ761HQD
Cc Python <python-list@python.org>
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.866.1366502229.3114.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366502229 news.xs4all.nl 2204 [2001:888:2000:d::a6]:48604
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43974

Show key headers only | View raw


On Sat, Apr 20, 2013 at 4:46 PM, Colin J. Williams <cjw@ncf.ca> wrote:
> Below is part of a script which shows the changes made to permit the script
> to run on either Python 2.7 or Python 3.2.
>
> I was surprised to see that the CSV next method is no longer available.
>
> Suggestions welcome.
<snip>
>     if ver == '2':
>        headerLine= inData.next()
>     else:  # Python version 3.3
<snip>
>         headerLine= inData.__next__()

Use the built-in next() function
(http://docs.python.org/2/library/functions.html#next ) instead:
    headerLine = next(iter(inData))

Cheers,
Chris

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


Thread

There must be a better way "Colin J. Williams" <cjw@ncf.ca> - 2013-04-20 19:46 -0400
  Re: There must be a better way Chris Rebert <clp2@rebertia.com> - 2013-04-20 16:57 -0700
  Re: There must be a better way Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-21 00:06 +0000
    Re: There must be a better way Tim Chase <python.list@tim.thechases.com> - 2013-04-20 19:34 -0500
    Re: There must be a better way Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-20 21:07 -0400
      Re: There must be a better way "Colin J. Williams" <cjw@ncf.ca> - 2013-04-21 09:15 -0400
        Re: There must be a better way Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-04-21 16:39 +0300
          Re: There must be a better way "Colin J. Williams" <cjw@ncf.ca> - 2013-04-21 11:17 -0400
        Re: There must be a better way Peter Otten <__peter__@web.de> - 2013-04-21 15:43 +0200
          Re: There must be a better way "Colin J. Williams" <cjw@ncf.ca> - 2013-04-21 11:30 -0400
          Re: There must be a better way "Colin J. Williams" <cjw@ncf.ca> - 2013-04-21 11:30 -0400
        Re: There must be a better way Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-22 15:32 +0100
        Re: There must be a better way Neil Cerutti <neilc@norwich.edu> - 2013-04-22 14:42 +0000
          Re: There must be a better way "Colin J. Williams" <cjw@ncf.ca> - 2013-04-22 13:44 -0400
            Re: There must be a better way Neil Cerutti <neilc@norwich.edu> - 2013-04-23 13:36 +0000
              Re: There must be a better way Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 15:15 +0100
              Re: There must be a better way Tim Chase <python.list@tim.thechases.com> - 2013-04-23 09:30 -0500
              Re: There must be a better way Skip Montanaro <skip@pobox.com> - 2013-04-23 09:36 -0500
              Re: There must be a better way (correction) Tim Chase <python.list@tim.thechases.com> - 2013-04-23 10:02 -0500

csiph-web