Good python equivalent to C goto
Michael Torrie
torriem at gmail.com
Sun Aug 17 00:37:34 EDT 2008
Kurien Mathew 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;
> }
I think the most direct translation would be this:
def whateverfunc():
def next_func():
stmt3
stmt4
while loopCondition:
if condition1:
next_func()
return
if condition2:
next_func()
return
if condition3:
next_func()
return
stmt1
stmt2
More information about the Python-list
mailing list