> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:python-
> [EMAIL PROTECTED] On Behalf Of Kurien Mathew
> Sent: Saturday, August 16, 2008 5:21 PM
> To: [email protected]
> Subject: Good python equivalent to C goto
>
> 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;
> }
>
===========================
Use a flag and a one loop for loop
while loopCondition:
flag = False
for i in range(1):
if condition1:
break
if condition2:
break
if condition3:
break
stmt1
stmt2
flag = True
if not flag:
stmt3
stmt4
===========================
Or just a straight flag
while ( loopCondition ):
flag = False
if (condition1)
flag = True # goto next;
if (not flag and condition2)
flag = True # goto next;
if (not flag and condition3)
flag = True # goto next;
if not flag:
stmt1
stmt2
else
stmt3
stmt4
*****
The information transmitted is intended only for the person or entity to which
it is addressed and may contain confidential, proprietary, and/or privileged
material. Any review, retransmission, dissemination or other use of, or taking
of any action in reliance upon this information by persons or entities other
than the intended recipient is prohibited. If you received this in error,
please contact the sender and delete the material from all computers. GA622
--
http://mail.python.org/mailman/listinfo/python-list