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: 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; '>': 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 To: Peter Otten <__peter__@web.de>, "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: References: , 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --_d6a2abda-2b1b-42b1-97e2-dbd402a3ea79_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks=2C 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=2C 22 Dec 2013 20:26:15 +0100 >=20 > Frank Cui wrote: >=20 > > hey guys=2C > > I have a requirement where I need to sequentially execute a bunch of > > executions=2C 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() =3D=3D 0: if b() =3D=3D 0: c() > > Thanks for your input. > > frank >=20 > funcs =3D a=2C b=2C c >=20 > # option 1 > for f in funcs: > if f(): > break >=20 > # option 2 > any(f() for f in funcs) >=20 >=20 > --=20 > https://mail.python.org/mailman/listinfo/python-list = --_d6a2abda-2b1b-42b1-97e2-dbd402a3ea79_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thanks=2C this looks beautiful
>=3B To: python-list@python.org
>=3B From: __peter__@web= .de
>=3B Subject: Re: cascading python executions only if return code = is 0
>=3B Date: Sun=2C 22 Dec 2013 20:26:15 +0100
>=3B
>=3B= Frank Cui wrote:
>=3B
>=3B >=3B hey guys=2C
>=3B >=3B = I have a requirement where I need to sequentially execute a bunch of
>= =3B >=3B executions=2C each execution has a return code. the followed exe= cutions
>=3B >=3B should only be executed if the return code is 0. i= s there a cleaner or
>=3B >=3B more pythonic way to do this other th= an the following ?
>=3B >=3B if a() =3D=3D 0: if b() =3D=3D 0: = c()
>=3B >=3B Thanks for your input.
>=3B >=3B frank
= >=3B
>=3B funcs =3D a=2C b=2C c
>=3B
>=3B # option 1
= >=3B for f in funcs:
>=3B if f():
>=3B break
>= =3B
>=3B # option 2
>=3B any(f() for f in funcs)
>=3B
&= gt=3B
>=3B --
>=3B https://mail.python.org/mailman/listinfo/pyt= hon-list
= --_d6a2abda-2b1b-42b1-97e2-dbd402a3ea79_--