Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62559
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.026 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'affected': 0.07; 'explicit': 0.07; 'subject:code': 0.07; '22,': 0.09; 'executed': 0.09; 'linear': 0.09; 'oop': 0.09; 'statements': 0.09; 'python': 0.11; 'question.': 0.14; '"n"': 0.16; 'a()': 0.16; 'b()': 0.16; 'cleaner': 0.16; 'cui': 0.16; 'pythonic': 0.16; 'semantics': 0.16; 'subject:python': 0.16; 'followed': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'bit': 0.19; 'examples': 0.20; 'later': 0.20; 'example': 0.22; 'to:name:python-list@python.org': 0.22; 'interpret': 0.24; 'logical': 0.24; 'earlier': 0.24; '(or': 0.24; 'question': 0.24; '>': 0.26; 'handling': 0.26; 'asking': 0.27; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'point': 0.28; 'function': 0.29; 'testing': 0.29; "doesn't": 0.30; 'dec': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'bunch': 0.31; 'purely': 0.31; 'there.': 0.32; 'url:python': 0.33; 'proceed': 0.33; 'third': 0.33; 'date:': 0.34; 'sense': 0.34; 'could': 0.34; 'problem': 0.35; 'advice': 0.35; 'december': 0.35; 'requirement': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'are,': 0.36; 'whilst': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'effort': 0.37; 'too': 0.37; 'email addr:python.org': 0.37; 'being': 0.38; 'depends': 0.38; 'solving': 0.38; 'to:addr:python-list': 0.38; 'received:65.54': 0.38; 'received:65.54.190': 0.38; 'received:bay0.hotmail.com': 0.38; 'previous': 0.38; 'rather': 0.38; 'subject:': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'skip:u 10': 0.60; 'mentioned': 0.61; 'took': 0.61; 'matter': 0.61; 'success': 0.61; 'kindly': 0.61; 'course': 0.61; "you're": 0.61; 'email addr:gmail.com': 0.63; 're:': 0.63; 'our': 0.64; 'provide': 0.64; 'more': 0.64; 'email name:python-list': 0.65; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'frank': 0.68; 'nobody': 0.68; 'wish': 0.70; 'clearer': 0.84; 'desperate': 0.84; 'offended': 0.84; 'adventure': 0.91; 'outcome': 0.93; '2013': 0.98 |
| X-TMN | [22T8HNsxKxwSp9ZilMfpwMfQUn7t6Dse] |
| X-Originating-Email | [ycui@outlook.com] |
| Content-Type | multipart/alternative; boundary="_d1167269-452f-4ae6-9257-d9a1a8d106cf_" |
| From | Frank Cui <ycui@outlook.com> |
| To | Rick Johnson <rantingrickjohnson@gmail.com>, "python-list@python.org" <python-list@python.org> |
| Subject | RE: cascading python executions only if return code is 0 |
| Date | Sun, 22 Dec 2013 19:14:13 -0300 |
| Importance | Normal |
| In-Reply-To | <bab87cd3-1993-4803-b13d-65ac786d29b6@googlegroups.com> |
| References | <bab87cd3-1993-4803-b13d-65ac786d29b6@googlegroups.com> |
| MIME-Version | 1.0 |
| X-OriginalArrivalTime | 22 Dec 2013 22:44:14.0376 (UTC) FILETIME=[56D3D280:01CEFF67] |
| 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.4514.1387752323.18130.python-list@python.org> (permalink) |
| Lines | 180 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1387752323 news.xs4all.nl 2936 [2001:888:2000:d::a6]:37288 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62559 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
> Date: Sun, 22 Dec 2013 14:27:35 -0800 > Subject: Re: cascading python executions only if return code is 0 > From: rantingrickjohnson@gmail.com > To: python-list@python.org > > On Sunday, December 22, 2013 12:37:04 PM UTC-6, Frank Cui wrote: > > 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() > > Hello Frank. > > I kindly request that you be more specific when asking > questions. Both your question and your example code contain > too many ambiguities. > > I'm still not sure what exact outcome you wish to achieve, > the only certainty is that you wish to perform a linear > execution of "N" members with later executions being affected > by earlier executions. > > Whether you want executions to proceed on failure or proceed > on success is unclear. Here are a few explicit pseudo code > examples that would have removed all ambiguities: > > if fails(a()): > if fails(b()): > c() > > if succeeds(a()): > if succeeds(b()): > c() > > Or if you prefer a purely OOP approach: > > a.foo() > b.foo() > if a.failed: > if b.failed: > c.foo() > > a.foo() > b.foo() > if a.succeeded: > if b.succeeded: > c.foo() > > or you could simplify using a logical one liner: > > if !a() and !b() then c() > if a() and b() then c() > > Of course you could use the "all" function > > if all(a(), b()): > c() > if not any(a(), b()): > c() > > But this "all" depends whether you're testing for success or > testing for failure, and that point is a distant third from > my desperate need of understanding your semantics of "what" > values are *true* and "what" values are *false*. > > I think (sadly) more time is spent attempting to interpret > what an OP is asking rather than attempting to provide a > solution to the problem the OP is suffering, and whilst any > problem solving adventure is likely to improve our > intelligence, fumbling about attempting to decode > ambiguities is indeed time that could have been better spent > IF ONLY the speaker (or writer) had put a small bit more > effort into the question. > > Look Frank, nobody is perfect, we all need to improve our > skills here or there. So don't be offended that my > statements are, well,... "frank". > > > -- > https://mail.python.org/mailman/listinfo/python-list Hi Rick, Thanks for pointing out. I accept your advice and will try to make the questions clearer and more straightforward to interpretate . I already took the suggestion of using exception-based handling over the return code. As to testing whether the previous function fails or succeeds, this doesn't really matter in the sense that I already mentioned a return code of 0. ThanksFrank
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
cascading python executions only if return code is 0 Frank Cui <ycui@outlook.com> - 2013-12-22 15:37 -0300
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-22 14:17 -0500
Re: cascading python executions only if return code is 0 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-22 19:31 +0000
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-22 15:05 -0500
Re: cascading python executions only if return code is 0 Cameron Simpson <cs@zip.com.au> - 2013-12-23 08:39 +1100
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-22 16:53 -0500
Re: cascading python executions only if return code is 0 Cameron Simpson <cs@zip.com.au> - 2013-12-23 09:11 +1100
Re: cascading python executions only if return code is 0 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-22 22:10 -0500
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-23 14:22 +1100
Re: cascading python executions only if return code is 0 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-23 03:43 +0000
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-23 14:45 +1100
Re: cascading python executions only if return code is 0 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-23 03:54 +0000
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-23 14:59 +1100
RE: cascading python executions only if return code is 0 Frank Cui <ycui@outlook.com> - 2013-12-22 16:10 -0300
Re: cascading python executions only if return code is 0 Ned Batchelder <ned@nedbatchelder.com> - 2013-12-22 14:49 -0500
Re: cascading python executions only if return code is 0 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-23 00:08 +0000
RE: cascading python executions only if return code is 0 Frank Cui <ycui@outlook.com> - 2013-12-22 16:35 -0300
Re: cascading python executions only if return code is 0 Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-12-23 13:30 +1300
Re: cascading python executions only if return code is 0 Rick Johnson <rantingrickjohnson@gmail.com> - 2013-12-22 14:27 -0800
RE: cascading python executions only if return code is 0 Frank Cui <ycui@outlook.com> - 2013-12-22 19:14 -0300
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-23 09:51 +1100
Re: cascading python executions only if return code is 0 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-22 23:02 +0000
Re: cascading python executions only if return code is 0 Rick Johnson <rantingrickjohnson@gmail.com> - 2013-12-22 15:57 -0800
Re: cascading python executions only if return code is 0 Ned Batchelder <ned@nedbatchelder.com> - 2013-12-23 07:27 -0500
Re: cascading python executions only if return code is 0 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-23 12:44 +0000
Re: cascading python executions only if return code is 0 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-23 00:25 +0000
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-22 20:24 -0500
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-23 12:35 +1100
Re: cascading python executions only if return code is 0 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-23 13:33 +1100
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-23 14:09 +1100
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-22 23:57 -0500
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-23 16:09 +1100
Re: cascading python executions only if return code is 0 Ethan Furman <ethan@stoneleaf.us> - 2013-12-23 04:45 -0800
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-23 10:10 -0500
Re: cascading python executions only if return code is 0 Ethan Furman <ethan@stoneleaf.us> - 2013-12-23 08:00 -0800
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-26 20:37 -0500
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-27 12:44 +1100
Re: cascading python executions only if return code is 0 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-26 21:20 -0500
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-27 13:27 +1100
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-26 23:29 -0500
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-27 15:40 +1100
Re: cascading python executions only if return code is 0 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-27 11:15 -0500
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-27 11:42 -0500
Re: cascading python executions only if return code is 0 Rustom Mody <rustompmody@gmail.com> - 2013-12-27 22:39 +0530
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-28 08:24 +1100
Re: cascading python executions only if return code is 0 pecore@pascolo.net - 2013-12-28 00:59 +0100
Re: cascading python executions only if return code is 0 Gene Heskett <gheskett@wdtv.com> - 2013-12-27 19:12 -0500
Re: cascading python executions only if return code is 0 Tim Chase <python.list@tim.thechases.com> - 2013-12-26 20:50 -0600
Re: cascading python executions only if return code is 0 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-27 15:39 +1100
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-27 15:45 +1100
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-27 00:05 -0500
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-27 16:15 +1100
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-27 00:41 -0500
Re: cascading python executions only if return code is 0 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-27 18:00 +0000
Re: cascading python executions only if return code is 0 Grant Edwards <invalid@invalid.invalid> - 2013-12-30 17:36 +0000
Re: cascading python executions only if return code is 0 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-24 04:05 +1100
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-23 11:03 -0800
Re: cascading python executions only if return code is 0 Chris Angelico <rosuav@gmail.com> - 2013-12-24 06:12 +1100
RE: cascading python executions only if return code is 0 Nick Cash <nick.cash@npcinternational.com> - 2013-12-23 19:31 +0000
Re: cascading python executions only if return code is 0 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-24 14:41 +1100
Re: cascading python executions only if return code is 0 Roy Smith <roy@panix.com> - 2013-12-23 22:58 -0500
Re: cascading python executions only if return code is 0 Peter Otten <__peter__@web.de> - 2013-12-23 18:45 +0100
Re: cascading python executions only if return code is 0 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-23 13:20 +0000
Re: cascading python executions only if return code is 0 Ethan Furman <ethan@stoneleaf.us> - 2013-12-23 04:38 -0800
Re: cascading python executions only if return code is 0 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-23 10:12 -0500
Re: cascading python executions only if return code is 0 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-24 04:13 +1100
Re: cascading python executions only if return code is 0 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-23 15:22 +0000
csiph-web