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


Groups > comp.lang.python > #34186

Re: Conversion of List of Tuples

Path csiph.com!usenet.pasdenom.info!aioe.org!rt.uk.eu.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ckaynor@zindagigames.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'that?': 0.05; 'lines.': 0.07; 'nested': 0.07; 'tuple': 0.09; 'cc:addr:python-list': 0.10; 'dec': 0.15; 'googling': 0.16; 'loops': 0.16; 'suggest?': 0.16; 'mon,': 0.16; 'wrote:': 0.17; '(in': 0.18; 'written': 0.20; 'received:209.85.216.46': 0.21; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'url:mailman': 0.29; 'url:python': 0.32; 'could': 0.32; 'url:listinfo': 0.32; 'much.': 0.33; 'subject:List': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'received:209.85': 0.35; 'url:org': 0.36; "didn't": 0.36; 'two': 0.37; 'item': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'list,': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'url:mail': 0.40; 'group,': 0.60; 'john': 0.60; 'dear': 0.66; 'levels': 0.66; 'kindly': 0.67
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:x-gm-message-state; bh=0rz4FQ6t5LIoyIcXL2M1mC7aYAtRF6c2O0IHv3XHBWA=; b=T6/Tu5w2E96yA3X9h8IREWgjxythDuNOPVT2WZz7Ew3iekUWO7GgjCO4yw3MI9yBIr 1R9oIEIF+EIAUoAQ3ZjDpyIwOqRUwB+aS8HhtpR7owQg8j7w/EKbNake2OgXF/Hg10ob aW8r0wnJ3Ix6Fy1my+AniAzmBhIP8oEEqeX+ebXgQPPlaOMcV43wH+/vv0LcfwRyFHJB SNlucjrsOXO+HkMj9ZsM2/h/K0Yw8OpqluC8ia06E4XTnySWAwo2dmiFEApwCn1+H3dm t1/J21pdIx7BKW/iMTrLWOabzIaWpMsb5cuSvNi/XgkkOFFRxl2zCvV6EQec0Ncv+7RM wTHg==
MIME-Version 1.0
In-Reply-To <6049bc85-6f8e-429b-a855-ecef47a9d28e@googlegroups.com>
References <6049bc85-6f8e-429b-a855-ecef47a9d28e@googlegroups.com>
From Chris Kaynor <ckaynor@zindagigames.com>
Date Mon, 3 Dec 2012 12:10:02 -0800
Subject Re: Conversion of List of Tuples
To subhabangalore@gmail.com
Content-Type text/plain; charset=ISO-8859-1
X-Gm-Message-State ALoCoQk8GDELqwUga3IdAR+IPuU76mhbYshzMTkPtKQ8UFWKWFzlf9je0hsDXE4y5I8E9Q3KC2gS
Cc "python-list@python.org" <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.437.1354565427.29569.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1354565427 news.xs4all.nl 6927 [2001:888:2000:d::a6]:39029
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34186

Show key headers only | View raw


On Mon, Dec 3, 2012 at 11:58 AM,  <subhabangalore@gmail.com> wrote:
> Dear Group,
>
> I have a tuple of list as,
>
> tup_list=[(1,2), (3,4)]
> Now if I want to covert as a simple list,
>
> list=[1,2,3,4]
>
> how may I do that?
>
> If any one can kindly suggest? Googling didn't help much.

If you know they are always exactly two levels deep, you can use
nested loops (in comprehension form):
[item for tuple_ in list_ for item in tuple_]

That could also be written how John recommended, in three lines.

>
> Regards,
> Subhabrata.
> --
> http://mail.python.org/mailman/listinfo/python-list

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


Thread

Conversion of List of Tuples subhabangalore@gmail.com - 2012-12-03 11:58 -0800
  Re: Conversion of List of Tuples John Gordon <gordon@panix.com> - 2012-12-03 20:04 +0000
    Re: Conversion of List of Tuples MRAB <python@mrabarnett.plus.com> - 2012-12-03 20:13 +0000
    Re: Conversion of List of Tuples Chris Angelico <rosuav@gmail.com> - 2012-12-04 07:17 +1100
  Re: Conversion of List of Tuples Chris Kaynor <ckaynor@zindagigames.com> - 2012-12-03 12:10 -0800
  Re: Conversion of List of Tuples subhabangalore@gmail.com - 2012-12-03 13:14 -0800
    Re: Conversion of List of Tuples John Gordon <gordon@panix.com> - 2012-12-03 22:02 +0000
    Re: Conversion of List of Tuples Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-03 22:11 +0000
      Re: Conversion of List of Tuples Walter Hurry <walterhurry@lavabit.com> - 2012-12-03 22:43 +0000
  Re: Conversion of List of Tuples Gary Herron <gherron@digipen.edu> - 2012-12-03 12:08 -0800
  Re: Conversion of List of Tuples Alexander Blinne <news@blinne.net> - 2012-12-04 10:44 +0100
    Re: Conversion of List of Tuples Hans Mulder <hansmu@xs4all.nl> - 2012-12-04 12:45 +0100
      Re: Conversion of List of Tuples Neil Cerutti <neilc@norwich.edu> - 2012-12-04 13:54 +0000

csiph-web