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


Groups > comp.lang.python > #62545

RE: cascading python executions only if return code is 0

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ycui@outlook.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:code': 0.07; 'executed': 0.09; 'python': 0.11; 'a()': 0.16; 'b()': 0.16; 'cleaner': 0.16; 'cui': 0.16; 'funcs': 0.16; 'guys,': 0.16; 'pythonic': 0.16; 'to:addr:web.de': 0.16; 'subject:python': 0.16; 'followed': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'hey': 0.18; 'to:name:python-list@python.org': 0.22; 'looks': 0.24; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'dec': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'bunch': 0.31; 'option': 0.32; 'url:python': 0.33; 'date:': 0.34; 'requirement': 0.35; 'there': 0.35; '+0100': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'email addr:python.org': 0.37; 'to:addr:python-list': 0.38; 'received:65.54': 0.38; 'received:65.54.190': 0.38; 'received:bay0.hotmail.com': 0.38; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'break': 0.61; 're:': 0.63; 'more': 0.64; 'email name:python-list': 0.65; 'beautiful': 0.68; 'frank': 0.68; '2013': 0.98
X-TMN [yl0hZsdrBc5C/angRPh3jE0FaZ25JtSz]
X-Originating-Email [ycui@outlook.com]
Content-Type multipart/alternative; boundary="_d6a2abda-2b1b-42b1-97e2-dbd402a3ea79_"
From Frank Cui <ycui@outlook.com>
To Peter Otten <__peter__@web.de>, "python-list@python.org" <python-list@python.org>
Subject RE: cascading python executions only if return code is 0
Date Sun, 22 Dec 2013 15:59:51 -0300
Importance Normal
In-Reply-To <l97ec4$c4c$1@ger.gmane.org>
References <l97ec4$c4c$1@ger.gmane.org>
MIME-Version 1.0
X-OriginalArrivalTime 22 Dec 2013 19:29:51.0717 (UTC) FILETIME=[2F574950:01CEFF4C]
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.4503.1387740660.18130.python-list@python.org> (permalink)
Lines 73
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1387740660 news.xs4all.nl 2891 [2001:888:2000:d::a6]:57669
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62545

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Thanks, this looks beautiful
> To: python-list@python.org
> From: __peter__@web.de
> Subject: Re: cascading python executions only if return code is 0
> Date: Sun, 22 Dec 2013 20:26:15 +0100
> 
> Frank Cui wrote:
> 
> > hey guys,
> > I have a requirement where I need to sequentially execute a bunch of
> > executions, each execution has a return code. the followed executions
> > should only be executed if the return code is 0. is there a cleaner or
> > more pythonic way to do this other than the following ?
> > if a() == 0:    if b() == 0:        c()
> > Thanks for your input.
> > frank
> 
> funcs = a, b, c
> 
> # option 1
> for f in funcs:
>     if f():
>         break
> 
> # option 2
> any(f() for f in funcs)
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
 		 	   		  

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


Thread

RE: cascading python executions only if return code is 0 Frank Cui <ycui@outlook.com> - 2013-12-22 15:59 -0300

csiph-web