Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51118
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.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.040 |
| X-Spam-Evidence | '*H*': 0.92; '*S*': 0.00; 'problem:': 0.07; '[3]:': 0.09; '24,': 0.16; 'comp': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Converting': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'pointed': 0.19; '>>>': 0.22; 'simpler': 0.24; 'skip:l 30': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; 'subject:lists': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'same.': 0.38; 'solving': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'simple': 0.61; 'complete': 0.62; 'different': 0.65; 'jul': 0.74; 'rafael': 0.84; '2013': 0.98 |
| 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:to :content-type:content-transfer-encoding; bh=e6QakPIVugvAu+LZqyCLeYX2ovCfv/+AryeWYmvg7cI=; b=ALAXVwOhoCS4HKNZkgK9SciX19Ono16D68opC68rsudF3MiCOV5tYKJaPs+aJU8tWY JW5GW3IWccw43j0coXStKAcyF2NgrMvq0EzOrCWAOl7rfKWIYmosJG9Ftm+2ADEt1D8G aZTcR3svSeiPVhKZhNZTNdd9GsoUeub/3aE1PjbERwt724c01NIVWH6CqSmuhVegI0Yo CMIjhLdjd70gKKjBp/kG4nx08jAEEwhmpSlUb0DkZgtc9vpgzx8HvuZZ2XxUR4WW4btm rxoYHMHz8/HwIKOpI6s1VbyWkkf0tVPwoxApPXSybbfUAqY78YAFp0YDHku64Pqs6/pP qonw== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.227.69 with SMTP id ry5mr68950vdc.83.1374644436128; Tue, 23 Jul 2013 22:40:36 -0700 (PDT) |
| In-Reply-To | <51EF04F7.9040401@gmail.com> |
| References | <ee6f5c48-6cb1-498f-813a-be2eef5411fc@googlegroups.com> <51EF04F7.9040401@gmail.com> |
| Date | Wed, 24 Jul 2013 15:40:36 +1000 |
| Subject | Re: Converting a list of lists to a single list |
| 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.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.5025.1374644439.3114.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1374644439 news.xs4all.nl 15899 [2001:888:2000:d::a6]:42760 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51118 |
Show key headers only | View raw
On Wed, Jul 24, 2013 at 8:34 AM, Rafael Durán Castañeda <rafadurancastaneda@gmail.com> wrote: > In [3]: [ y for y in itertools.chain.from_iterable(x)] > Out[3]: ['A0', 'A1', 'A2', 'B0', 'B1', 'B2', 'C0', 'C1', 'C2'] Complete aside, given that this has already been pointed out as solving a different problem: Any time you see a list comp that just does "[ x for x in foo ]", check to see if it can be replaced by a simple list constructor: >>> [ y for y in itertools.chain.from_iterable(x)] ['A0', 'A1', 'A2', 'B0', 'B1', 'B2', 'C0', 'C1', 'C2'] >>> list(itertools.chain.from_iterable(x)) ['A0', 'A1', 'A2', 'B0', 'B1', 'B2', 'C0', 'C1', 'C2'] A bit simpler and achieves the same. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Converting a list of lists to a single list steve@divillo.com - 2013-07-23 14:52 -0700 Re: Converting a list of lists to a single list Rafael Durán Castañeda <rafadurancastaneda@gmail.com> - 2013-07-24 00:34 +0200 Re: Converting a list of lists to a single list MRAB <python@mrabarnett.plus.com> - 2013-07-23 23:52 +0100 Re: Converting a list of lists to a single list Zero Piraeus <schesis@gmail.com> - 2013-07-23 18:49 -0400 Re: Converting a list of lists to a single list Terry Reedy <tjreedy@udel.edu> - 2013-07-23 19:02 -0400 Re: Converting a list of lists to a single list Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-23 20:28 -0400 Re: Converting a list of lists to a single list Chris Angelico <rosuav@gmail.com> - 2013-07-24 15:40 +1000 Re: Converting a list of lists to a single list Terry Reedy <tjreedy@udel.edu> - 2013-07-24 11:56 -0400 Re: Converting a list of lists to a single list steve@divillo.com - 2013-07-24 11:11 -0700
csiph-web