cascading python executions only if return code is 0

Mark Lawrence breamoreboy at
Mon Dec 23 00:02:51 CET 2013

On 22/12/2013 22:51, Chris Angelico wrote:
> On Mon, Dec 23, 2013 at 9:14 AM, Frank Cui <ycui at> wrote:
>> Thanks for pointing out. I accept your advice and will try to make the
>> questions clearer and more straightforward to interpretate . I already took
>> the suggestion of using exception-based handling over the return code.
>> As to testing whether the previous function fails or succeeds, this doesn't
>> really matter in the sense that I already mentioned a return code of 0.
> Ranting Rick is one of the list's resident trolls. Don't take it amiss
> that he turned his flamethrowers on you. :)
> ChrisA

Given that Frank originally stated this

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:

I can only see one way that you can possibly intepret it.  Perhaps rr 
was dashing off a reply on a mobile device while doing a home run, hence 
wasn't concentrating on what Frank had actually said?

My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

More information about the Python-list mailing list