Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'parameters': 0.04; 'true,': 0.05; 'subject:code': 0.07; 'executed': 0.09; 'lawrence': 0.09; 'means,': 0.09; 'operand': 0.09; 'python': 0.11; 'language.': 0.14; '"or"': 0.16; '>>': 0.16; 'a()': 0.16; 'b()': 0.16; 'cleaner': 0.16; 'cui': 0.16; 'guys,': 0.16; 'pythonic': 0.16; 'really?': 0.16; 'roy': 0.16; 'subject:python': 0.16; 'followed': 0.16; 'language': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'hey': 0.18; '+0000': 0.22; 'to:name:python- list@python.org': 0.22; 'sorry,': 0.24; '>': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'dec': 0.30; 'skip:& 60': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'bunch': 0.31; 'url:python': 0.33; 'date:': 0.34; 'something': 0.35; 'requirement': 0.35; 'but': 0.35; 'there': 0.35; 'false': 0.36; 'otherwise.': 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; 'sure': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'first': 0.61; 're:': 0.63; 'our': 0.64; 'more': 0.64; 'different': 0.65; 'email name:python-list': 0.65; 'frank': 0.68; 'smith': 0.68; 'evaluate': 0.72; 'article': 0.77; 'do:': 0.91; '2013': 0.98 X-TMN: [cXcoXHkuyfL7ZN+FYc+bcxe74+Huv3gc] X-Originating-Email: [ycui@outlook.com] Content-Type: multipart/alternative; boundary="_7d5d5792-9c60-4e02-a414-8f653753f533_" From: Frank Cui To: "python-list@python.org" Subject: RE: cascading python executions only if return code is 0 Date: Sun, 22 Dec 2013 16:10:36 -0300 Importance: Normal In-Reply-To: References: , , MIME-Version: 1.0 X-OriginalArrivalTime: 22 Dec 2013 19:40:37.0266 (UTC) FILETIME=[B01E3F20:01CEFF4D] 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: 99 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387741305 news.xs4all.nl 2925 [2001:888:2000:d::a6]:36532 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62547 --_7d5d5792-9c60-4e02-a414-8f653753f533_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable sorry=2C but what if I need to have different parameters in these functions= ? > To: python-list@python.org > From: breamoreboy@yahoo.co.uk > Subject: Re: cascading python executions only if return code is 0 > Date: Sun=2C 22 Dec 2013 19:31:21 +0000 >=20 > On 22/12/2013 19:17=2C Roy Smith wrote: > > In article =2C > > Frank Cui wrote: > > > >> 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 execution= s should > >> only be executed if the return code is 0. is there a cleaner or more p= ythonic > >> way to do this other than the following ? > >> if a() =3D=3D 0: if b() =3D=3D 0: c() > >> Thanks for your input. > >> frank =09 > > > > Yup! Just do: > > > > a() or b() or c() > > > > The "or" operation has what's known as "short-circuit" semantics. That > > means=2C if the first operand is true=2C it doesn't evaluate the second > > operand. Just make sure that a()=2C b()=2C and c() all return somethin= g > > which is true if they succeed and false otherwise. > > >=20 > Really? :) >=20 > --=20 > My fellow Pythonistas=2C ask not what our language can do for you=2C ask= =20 > what you can do for our language. >=20 > Mark Lawrence >=20 > --=20 > https://mail.python.org/mailman/listinfo/python-list = --_7d5d5792-9c60-4e02-a414-8f653753f533_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
sorry=2C but what if I need to h= ave different parameters in these functions ?


=
>=3B To: python-list@python.org
>=3B From: breamoreboy@yah= oo.co.uk
>=3B Subject: Re: cascading python executions only if return = code is 0
>=3B Date: Sun=2C 22 Dec 2013 19:31:21 +0000
>=3B
&= gt=3B On 22/12/2013 19:17=2C Roy Smith wrote:
>=3B >=3B In article &= lt=3Bmailman.4500.1387739297.18130.python-list@python.org>=3B=2C
>= =3B >=3B Frank Cui <=3Bycui@outlook.com>=3B wrote:
>=3B >=3B=
>=3B >=3B>=3B hey guys=2C
>=3B >=3B>=3B I have a require= ment where I need to sequentially execute a bunch of
>=3B >=3B>=3B= executions=2C each execution has a return code. the followed executions sh= ould
>=3B >=3B>=3B only be executed if the return code is 0. is th= ere a cleaner or more pythonic
>=3B >=3B>=3B way to do this other = than the following ?
>=3B >=3B>=3B if a() =3D=3D 0: if b() =3D= =3D 0: c()
>=3B >=3B>=3B Thanks for your input.
>=3B &= gt=3B>=3B frank
>=3B >=3B
>=3B >=3B Yup! Just do= :
>=3B >=3B
>=3B >=3B a() or b() or c()
>=3B >=3B
&= gt=3B >=3B The "or" operation has what's known as "short-circuit" semanti= cs. That
>=3B >=3B means=2C if the first operand is true=2C it does= n't evaluate the second
>=3B >=3B operand. Just make sure that a()= =2C b()=2C and c() all return something
>=3B >=3B which is true if t= hey succeed and false otherwise.
>=3B >=3B
>=3B
>=3B Real= ly? :)
>=3B
>=3B --
>=3B My fellow Pythonistas=2C ask not = what our language can do for you=2C ask
>=3B what you can do for our = language.
>=3B
>=3B Mark Lawrence
>=3B
>=3B --
&g= t=3B https://mail.python.org/mailman/listinfo/python-list
=
= --_7d5d5792-9c60-4e02-a414-8f653753f533_--