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


Groups > comp.lang.python > #10996

Re: how to separate a list into two lists?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.041
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'subject:two': 0.07; 'momentarily': 0.09; 'am,': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.16; 'subject:list': 0.18; 'header:In-Reply-To:1': 0.22; 'aug': 0.24; 'guess': 0.26; 'loop': 0.28; 'order.': 0.29; 'message-id:@mail.gmail.com': 0.29; 'sun,': 0.30; 'subject:?': 0.31; "what's": 0.33; 'to:addr:python- list': 0.33; 'do?': 0.34; 'subject:lists': 0.36; 'question': 0.36; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'why': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40; 'more': 0.60; 'wish': 0.69; 'roberts': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=9u/p2d+jPJiIdrQefuoVjzj+wkk9dqxQEto7K9tUVfQ=; b=WPOwBsC+ypqyGLfPStIJeGKzTf5Gu+ODITLfYeZmmoP1KJyHwq9rUePFAe76kTZY0g HERjY94f1BABAEZgaPNhal7J39jyiYGGo8jrziutHkCoJRYCEMpApxSKGPHA2c3Y491h Dvcs0WcNb1hy1NnHefXihr/EFOVkEOugYbMtI=
MIME-Version 1.0
In-Reply-To <mfor37tgmao0e5mlvllj02kgo2esp25dcd@4ax.com>
References <mailman.1983.1312650424.1164.python-list@python.org> <mfor37tgmao0e5mlvllj02kgo2esp25dcd@4ax.com>
Date Sun, 7 Aug 2011 02:05:14 +0100
Subject Re: how to separate a list into two lists?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.2002.1312679117.1164.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312679117 news.xs4all.nl 23837 [2001:888:2000:d::a6]:55461
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10996

Show key headers only | View raw


On Sun, Aug 7, 2011 at 1:58 AM, Tim Roberts <timr@probo.com> wrote:
> I did momentarily consider the following slimy solution:
>  L1 = dict(L).keys()
>  L2 = dict(L).values()
> but that reorders the tuples.  They still correspond, but in a different
> order.
>

Which can be overcome with collections.OrderedDict. But what's dict(L)
going to do? It's going to loop over L, more than once in fact.

I guess the real question is: Why do you wish to avoid a loop?

ChrisA

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


Thread

how to separate a list into two lists? smith jack <thinke365@gmail.com> - 2011-08-07 01:07 +0800
  Re: how to separate a list into two lists? bud <only@fleshwound.org> - 2011-08-06 18:13 +0000
    Re: how to separate a list into two lists? Gelonida N <gelonida@gmail.com> - 2011-08-06 22:00 +0200
      Re: how to separate a list into two lists? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-07 10:07 +1000
        Re: how to separate a list into two lists? Gelonida N <gelonida@gmail.com> - 2011-08-07 19:11 +0200
  Re: how to separate a list into two lists? Tim Roberts <timr@probo.com> - 2011-08-06 17:58 -0700
    Re: how to separate a list into two lists? Chris Angelico <rosuav@gmail.com> - 2011-08-07 02:05 +0100
      Re: how to separate a list into two lists? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-07 11:35 +1000
  Re: how to separate a list into two lists? Paul Rubin <no.email@nospam.invalid> - 2011-08-06 22:29 -0700

csiph-web