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


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

Re: cascading python executions only if return code is 0

Started byPeter Otten <__peter__@web.de>
First post2013-12-22 20:26 +0100
Last post2013-12-22 20:26 +0100
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 Peter Otten <__peter__@web.de> - 2013-12-22 20:26 +0100

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

FromPeter Otten <__peter__@web.de>
Date2013-12-22 20:26 +0100
SubjectRe: cascading python executions only if return code is 0
Message-ID<mailman.4501.1387740383.18130.python-list@python.org>
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

funcs = a, b, c

# option 1
for f in funcs:
    if f():
        break

# option 2
any(f() for f in funcs)

[toc] | [standalone]


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


csiph-web