Good python equivalent to C goto

Fredrik Lundh fredrik at pythonware.com
Sat Aug 16 17:33:19 EDT 2008


Kurien Mathew wrote:

> 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;
>  }

seems as if you *don't* want to execute the first part if any of the 
conditions are true.  in other words,

    while loopCondition:
       if not (condition1 or condition2 or condition3):
           stmt1
           stmt2
       stmt3
       stmt4

</F>




More information about the Python-list mailing list