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


Groups > comp.lang.python > #44221

Re: Nested iteration?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.034
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; '[1,': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'creates': 0.14; 'benjamin': 0.16; 'iterator': 0.16; 'loop.': 0.16; 'starred': 0.16; 'unpacking': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:gmail.com': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; '&gt;&gt;&gt;': 0.24; 'convenient': 0.24; 'first,': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'd": 0.34; 'problem': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'doing': 0.36; 'method': 0.36; 'subject:?': 0.36; 'list': 0.37; 'new': 0.61; 'numbers': 0.61; "you're": 0.61; "you'll": 0.62; 'talking': 0.65; 'to:addr:gmail.com': 0.65; 'oscar': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=Our6MUB7pjvu7iKEoF+whY7p9tJE4rgCnD0JbaWQugg=; b=GkXJ68i8BjCcsSJvv8ZDc4FERAeTuPV5kwhrnKz4ZQ8uuTILACHE2IbRn8Y4aXG1Y6 ptQUBZEui2Jx5EnZ1WHknNlPqhnfAs0Zdrh1rV8uuviSJqgSTXl9r5Hyxtsx6/LStm2y u2oSUqTMj+fAc2f+k7YUJqUJ+M5+yX/7MM+pgPoQCa4xcuVQ97U03NAqROK6kcKzYsjH oQhHQKmNmNT7+uVUWf30TwZvTQVg3F0sOTwe9TmXsYOZqCKsIlYIwMFPH+2zeNJkRwqU ggxwFlUYVHnmoxOUtG3A5Eq/GBRPDrWLxh1QHG+R7mMC2eelbVhhfnAwSRU1DnsSdHZw Kmxg==
X-Received by 10.112.3.202 with SMTP id e10mr16586746lbe.84.1366753301184; Tue, 23 Apr 2013 14:41:41 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CAHVvXxROqnNt1bwvvQLNNUczGbFDUdZ7yu3=Om3DQHaekzZj-g@mail.gmail.com>
References <kl6a1f$k2l$1@panix2.panix.com> <CAPTjJmpKR8z7Cub1WaurmsuugNgCvPYFdh9WYqJd_1OTfpLw6Q@mail.gmail.com> <CALwzidk6qz4qHOFWYqv_cDEtjbhvS_kjG0vXJZmeB0dJ07doTQ@mail.gmail.com> <CAHVvXxROqnNt1bwvvQLNNUczGbFDUdZ7yu3=Om3DQHaekzZj-g@mail.gmail.com>
From Joshua Landau <joshua.landau.ws@gmail.com>
Date Tue, 23 Apr 2013 22:41:00 +0100
Subject Re: Nested iteration?
To Oscar Benjamin <oscar.j.benjamin@gmail.com>
Content-Type multipart/alternative; boundary=14dae9473a7903496f04db0e0d7a
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.997.1366753308.3114.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366753308 news.xs4all.nl 2275 [2001:888:2000:d::a6]:58494
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44221

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 23 April 2013 22:29, Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:

> I just thought I'd add that Python 3 has a convenient way to avoid
> this problem with next() which is to use the starred unpacking syntax:
>
> >>> numbers = [1, 2, 3, 4]
> >>> first, *numbers = numbers
>

That creates a new list every time. You'll not want that over
try-next-except if you're doing this in a loop, and on addition (if you
were talking in context) your method will exhaust the iterator in the outer
loop.

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


Thread

Nested iteration? roy@panix.com (Roy Smith) - 2013-04-23 11:40 -0400
  Re: Nested iteration? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 17:05 +0100
  Re: Nested iteration? Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-23 10:05 -0600
  Re: Nested iteration? Peter Otten <__peter__@web.de> - 2013-04-23 18:15 +0200
  Re: Nested iteration? Chris Angelico <rosuav@gmail.com> - 2013-04-24 02:21 +1000
  Re: Nested iteration? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 16:35 +0000
  Re: Nested iteration? Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-23 10:30 -0600
  Re: Nested iteration? Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-23 10:39 -0600
  Re: Nested iteration? Chris Angelico <rosuav@gmail.com> - 2013-04-24 02:42 +1000
    Re: Nested iteration? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 16:53 +0000
  Re: Nested iteration? Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-23 16:49 -0400
  Re: Nested iteration? Joshua Landau <joshua.landau.ws@gmail.com> - 2013-04-23 22:14 +0100
  Re: Nested iteration? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 22:29 +0100
  Re: Nested iteration? Joshua Landau <joshua.landau.ws@gmail.com> - 2013-04-23 22:41 +0100
  Re: Nested iteration? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-23 23:42 +0100

csiph-web