On Aug 16, 11:20 pm, Kurien Mathew <[EMAIL PROTECTED]> wrote: > Hello, > > Any suggestions on a good python equivalent for the following C code: > > while (loopCondition) > { > if (condition1) > goto next; > if (condition2) > goto next; > if (condition3) > goto next; > stmt1; > stmt2; > next: > stmt3; > stmt4; > }
Extract complex test as a function. Assuming conditions 1, 2 and 3 are difficult enough not to put them all one one line, put them in a function which describes what they're testing. def should_do_12(args): if condition1: return False if condition2: return False if condition3: return False return True while loop_condition: if should_do_12(args): stmt1 stmt2 stmt3 stmt4 This is probably the right way to write it in C too. -- Paul Hankin -- http://mail.python.org/mailman/listinfo/python-list