Is there a more elegant way to spell this?

Rob Gaddi rgaddi at technologyhighland.invalid
Tue Jan 27 12:49:11 EST 2015


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

> On Jan 27, 2015 2:16 PM, "Neal Becker" <ndbecker2 at 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.



More information about the Python-list mailing list