Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62544
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <gary.herron@islandtraining.com> |
| 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; 'subject:code': 0.07; 'executed': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'a()': 0.16; 'b()': 0.16; 'cleaner': 0.16; 'cui': 0.16; 'guys,': 0.16; 'pythonic': 0.16; 'subject:python': 0.16; 'followed': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'hey': 0.18; 'header:User-Agent:1': 0.23; 'received:emailsrvr.com': 0.24; 'received:(smtp server)': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'code': 0.31; 'bunch': 0.31; 'could': 0.34; 'requirement': 0.35; 'there': 0.35; 'thanks': 0.36; 'should': 0.36; 'easily': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'break': 0.61; 'extended': 0.61; 'more': 0.64; 'frank': 0.68 |
| X-Virus-Scanned | OK |
| Date | Sun, 22 Dec 2013 11:21:06 -0800 |
| From | Gary Herron <gary.herron@islandtraining.com> |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: cascading python executions only if return code is 0 |
| References | <BAY176-W34BAA8F2DF045E2B8CAC7ADAC60@phx.gbl> |
| In-Reply-To | <BAY176-W34BAA8F2DF045E2B8CAC7ADAC60@phx.gbl> |
| Content-Type | multipart/alternative; boundary="------------030504020901080200080107" |
| 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.4502.1387740402.18130.python-list@python.org> (permalink) |
| Lines | 96 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1387740403 news.xs4all.nl 2936 [2001:888:2000:d::a6]:52146 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62544 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 12/22/2013 10:37 AM, 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
>
>
This would seem to do the same as your code and could easily be extended
to your "bunch" of things:
exes = [a, b, c]
for e in exes:
if e() != 0:
break
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: cascading python executions only if return code is 0 Gary Herron <gary.herron@islandtraining.com> - 2013-12-22 11:21 -0800
csiph-web