Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62543
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: cascading python executions only if return code is 0 |
| Date | 2013-12-22 20:26 +0100 |
| Organization | None |
| References | <BAY176-W34BAA8F2DF045E2B8CAC7ADAC60@phx.gbl> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4501.1387740383.18130.python-list@python.org> (permalink) |
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)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: cascading python executions only if return code is 0 Peter Otten <__peter__@web.de> - 2013-12-22 20:26 +0100
csiph-web