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?

From Neal Becker <ndbecker2@gmail.com>
Subject Re: Is there a more elegant way to spell this?
Date 2015-01-27 09:37 -0500
References <mailman.18170.1422364524.18130.python-list@python.org> <qot7fw8s3la.fsf@ruuvi.it.helsinki.fi>
Newsgroups comp.lang.python
Message-ID <mailman.18173.1422369489.18130.python-list@python.org> (permalink)

Show all headers | 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