cascading python executions only if return code is 0
gary.herron at islandtraining.com
Sun Dec 22 20:21:06 CET 2013
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:
> Thanks for your input.
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:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list