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


Groups > comp.lang.python > #84647

Re: Is there a more elegant way to spell this?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'elegant': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'better:': 0.16; 'ifilter': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.18; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'possibly': 0.26; 'header:X -Complaints-To:1': 0.27; 'writes:': 0.31; 'this.': 0.32; 'probably': 0.32; 'except': 0.35; 'there': 0.35; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'subject:more': 0.64; 'more': 0.64; 'subject:there': 0.68; 'subject:this': 0.83; 'received:139': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Neal Becker <ndbecker2@gmail.com>
Subject Re: Is there a more elegant way to spell this?
Date Tue, 27 Jan 2015 09:37:49 -0500
References <mailman.18170.1422364524.18130.python-list@python.org> <qot7fw8s3la.fsf@ruuvi.it.helsinki.fi>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host exa2-in-fw-01-epn.hns.com
User-Agent KNode/4.14.3
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.18173.1422369489.18130.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1422369489 news.xs4all.nl 2839 [2001:888:2000:d::a6]:57033
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:84647

Show key headers only | View raw


Jussi Piitulainen wrote:

> Neal Becker writes:
> 
>> Is there a more elegant way to spell this?
>> 
>> for x in [_ for _ in seq if some_predicate]:
> 
> If you mean some_predicate(_), then possibly this.
> 
> for x in filter(some_predicate, seq):
>    handle(x)
> 

I like this best, except probably even better:

for x in ifilter (some_predicate, seq):

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


Thread

Is there a more elegant way to spell this? Neal Becker <ndbecker2@gmail.com> - 2015-01-27 08:15 -0500
  Re: Is there a more elegant way to spell this? Rustom Mody <rustompmody@gmail.com> - 2015-01-27 06:08 -0800
  Re: Is there a more elegant way to spell this? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-01-27 16:25 +0200
    Re: Is there a more elegant way to spell this? Neal Becker <ndbecker2@gmail.com> - 2015-01-27 09:37 -0500
      Re: Is there a more elegant way to spell this? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-01-27 16:47 +0200
    Re: Is there a more elegant way to spell this? Mario Figueiredo <marfig@gmail.com> - 2015-01-27 19:05 +0100
      Re: Is there a more elegant way to spell this? random832@fastmail.us - 2015-01-27 13:13 -0500
    Re: Is there a more elegant way to spell this? Neal Becker <ndbecker2@gmail.com> - 2015-01-27 13:25 -0500
  Re: Is there a more elegant way to spell this? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 11:55 +1100
    Re: Is there a more elegant way to spell this? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 02:19 +0100
      Re: Is there a more elegant way to spell this? Ben Finney <ben+python@benfinney.id.au> - 2015-01-28 12:29 +1100
        Re: Is there a more elegant way to spell this? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 09:32 +0100
      Re: Is there a more elegant way to spell this? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 13:16 +1100

csiph-web