Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64206
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <drsalists@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'elegant': 0.07; 'expressions': 0.07; 'string': 0.09; 'lines.': 0.09; 'subject:skip:c 10': 0.09; 'things,': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'cc:name:python list': 0.16; 'mylist': 0.16; 'name)': 0.16; 'readable': 0.16; 'wrote:': 0.18; 'pfxlen:0': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'hi,': 0.36; 'list': 0.37; 'skip:[ 10': 0.38; 'pm,': 0.38; 'little': 0.38; 'then,': 0.60; 'name': 0.63; 'become': 0.64; 'great': 0.65; 'physical': 0.72; 'subject:this': 0.83 |
| 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 :cc:content-type; bh=aXkRx5JyrME/LYIZZ74bg1wpCTea5RNzD+rGfBEcZpo=; b=07XCH5s0m1vAyH9uYHSw762bzP5AAkCZFZEkn3q4DHiPj1dSou9D5c46J0jwSzqkAq +9pPRWkDf7xVcLzRtiISVmLe6wFq4Seevqd/2rWylNxb6/x8tXpu6WWon7YYdf1UgGQh s5pqvv5TZ+87rnm2s2ZBj5F6Si7eVYG4rBZRJgWbOlM8nipQyVxckKNuJQQwBuPiXZeR 6F4rfLqEytL4IfyMtDhRCFOyBpkhqXHmWObtSs9uCpLk1HNJR4rFMqx9HPaxwiQ0Dp+7 bNsTQU2zl7LQJBiIBwL4P4GcsyWWqpvACEtnjHq483Fnd/0NBhwTW4AhmCjh49T3miIH L0vw== |
| MIME-Version | 1.0 |
| X-Received | by 10.180.205.162 with SMTP id lh2mr577720wic.57.1390002561821; Fri, 17 Jan 2014 15:49:21 -0800 (PST) |
| In-Reply-To | <m2sism42n8.fsf@cochabamba.vanoostrum.org> |
| References | <m2sism42n8.fsf@cochabamba.vanoostrum.org> |
| Date | Fri, 17 Jan 2014 15:49:21 -0800 |
| Subject | Re: How to write this as a list comprehension? |
| From | Dan Stromberg <drsalists@gmail.com> |
| To | Piet van Oostrum <piet@vanoostrum.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | Python List <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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5665.1390002563.18130.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1390002563 news.xs4all.nl 2953 [2001:888:2000:d::a6]:40043 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64206 |
Show key headers only | View raw
On Fri, Jan 17, 2014 at 3:19 PM, Piet van Oostrum <piet@vanoostrum.org> wrote: > Hi, > > I am looking for an elegant way to write the following code as a list > comprehension: > > labels = [] > for then, name in mylist: > _, mn, dy, _, _, _, wd, _, _ = localtime(then) > labels.append(somefunc(mn, day, wd, name)) My recomendation: Don't use a list comprehension. List comprehensions and generator expressions are great for quick little things, but become less readable when you have to string them over multiple physical lines. > labels = [somefunc(mn, day, wd, name) > for then, name in mylist > for _, mn, dy, _, _, _, wd, _, _ in [localtime(then)]]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to write this as a list comprehension? Piet van Oostrum <piet@vanoostrum.org> - 2014-01-18 00:19 +0100
Re: How to write this as a list comprehension? Dan Stromberg <drsalists@gmail.com> - 2014-01-17 15:49 -0800
Re: How to write this as a list comprehension? Rustom Mody <rustompmody@gmail.com> - 2014-01-17 19:25 -0800
Re: How to write this as a list comprehension? Piet van Oostrum <piet@vanoostrum.org> - 2014-01-18 11:00 +0100
Re: How to write this as a list comprehension? Peter Otten <__peter__@web.de> - 2014-01-18 09:36 +0100
Re: How to write this as a list comprehension? Rustom Mody <rustompmody@gmail.com> - 2014-01-18 07:20 -0800
Re: How to write this as a list comprehension? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-18 18:00 +0200
Re: How to write this as a list comprehension? "Rhodri James" <rhodri@wildebst.org.uk> - 2014-01-19 23:41 +0000
Re: How to write this as a list comprehension? Piet van Oostrum <piet@vanoostrum.org> - 2014-01-20 12:02 +0100
Re: How to write this as a list comprehension? Rustom Mody <rustompmody@gmail.com> - 2014-01-20 03:47 -0800
Re: How to write this as a list comprehension? matej@ceplovi.cz (Matěj Cepl) - 2014-01-18 11:57 +0100
Re: How to write this as a list comprehension? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-01-18 12:53 +0100
Re: How to write this as a list comprehension? Piet van Oostrum <piet@vanoostrum.org> - 2014-01-18 18:40 +0100
Re: How to write this as a list comprehension? John Allsup <pydev@allsup.co> - 2014-01-19 01:24 +0000
Re: How to write this as a list comprehension? Piet van Oostrum <piet@vanoostrum.org> - 2014-01-19 23:06 +0100
csiph-web