Good python equivalent to C goto
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Sun Aug 17 04:56:40 EDT 2008
On Sat, 16 Aug 2008 23:20:52 +0200, 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;
> }
(Don't) use the `goto` module: http://entrian.com/goto/ :-)
from goto import goto, label
# ...
while loop_condition:
if condition1 or condition2 or condition3:
goto .next
print 'stmt1'
print 'stmt2'
label .next
print 'stmt3'
print 'stmt4'
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list