I would like to know if there is an elegant way to create a GoTo LABEL structure with Python such as it is possible on Visual Basic. I have read that it kind of depends on case to case, but let's assume that I have a loop like the following (executable):
for i in range(0,10):
print "LOOP", i, "- DO SOMETHING ALL TIMES"
print "LOOP", i, "- DO SOMETHING SOME TIMES"
print "LOOP", i, "- DO SOMETHING ELSE ALL TIMES"
print ""
What I would like to know is if it's possible to skip the middle instruction, namely print "LOOP", i, "- DO SOMETHING SOME TIMES"
, with a construction like the following that (badly simulating the Visual Basic syntaxis) should allow the script to skip the instruction "do something some times" if i is equal to 3:
for i in range(0,10):
print "LOOP", i, "- DO SOMETHING ALL TIMES"
if i == 3: (GoTo SECONDPART)
print "LOOP", i, "-DO SOMETHING SOME TIMES"
SECONDPART:
print "LOOP", i, "-DO SOMETHING ALL TIMES"
I know that I could write if i != 3:
and indent the instruction "do something some times", but I'd really like to know if possible to have (or himitate) the GoTo structure of other languages. Thanks a lot, I hope it's clear (if not don't hesitate to ask!)