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


Groups > comp.lang.python > #84657

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

From Rob Gaddi <rgaddi@technologyhighland.invalid>
Newsgroups comp.lang.python
Subject Re: Is there a more elegant way to spell this?
Date 2015-01-27 09:49 -0800
Organization Highland Technology, Inc.
Message-ID <20150127094911.236b6e6d@rg.highlandtechnology.com> (permalink)
References <ma8311$q4c$1@ger.gmane.org> <mailman.18171.1422364818.18130.python-list@python.org>

Show all headers | View raw


On Tue, 27 Jan 2015 14:20:10 +0100
Chris Warrick <kwpolska@gmail.com> wrote:

> On Jan 27, 2015 2:16 PM, "Neal Becker" <ndbecker2@gmail.com> wrote:
> >
> > Is there a more elegant way to spell this?
> >
> > for x in [_ for _ in seq if some_predicate]:
> 
> for x in seq:
>     if some_predicate:
>         do_something_to(x)
> 
> -- 
> Chris Warrick <https://chriswarrick.com/>
> Sent from my Galaxy S3.
> 
Or the somewhat less indenty

for x in seq:
    if not some_predicate: continue
    do_something_to(x)

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.

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


Thread

Re: Is there a more elegant way to spell this? Chris Warrick <kwpolska@gmail.com> - 2015-01-27 14:20 +0100
  Re: Is there a more elegant way to spell this? Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-01-27 09:49 -0800
    Re: Is there a more elegant way to spell this? Emile van Sebille <emile@fenx.com> - 2015-01-27 10:27 -0800

csiph-web