cascading python executions only if return code is 0
Frank Cui
ycui at outlook.com
Sun Dec 22 13:59:51 EST 2013
Thanks, this looks beautiful
> To: python-list at python.org
> From: __peter__ at web.de
> Subject: Re: cascading python executions only if return code is 0
> Date: Sun, 22 Dec 2013 20:26:15 +0100
>
> 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)
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131222/38e72079/attachment.html>
More information about the Python-list
mailing list