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


Groups > comp.lang.python > #62544 > unrolled thread

Re: cascading python executions only if return code is 0

Started byGary Herron <gary.herron@islandtraining.com>
First post2013-12-22 11:21 -0800
Last post2013-12-22 11:21 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: cascading python executions only if return code is 0 Gary Herron <gary.herron@islandtraining.com> - 2013-12-22 11:21 -0800

#62544 — Re: cascading python executions only if return code is 0

FromGary Herron <gary.herron@islandtraining.com>
Date2013-12-22 11:21 -0800
SubjectRe: cascading python executions only if return code is 0
Message-ID<mailman.4502.1387740402.18130.python-list@python.org>

[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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web