[Tutor] try except continue
tpc at csua.berkeley.edu
Thu Jul 28 19:45:02 CEST 2005
hey guys, so I've been trying to get my head around the try except
statement in Python, and ideally what I'd like is for my procedural
program, when it runs through its steps and encounters an error, to log
the error and pick up where it left off and keep going. According to this
link, 'continue' is allowed within an except or finally:
I tried to run the following code, expecting to catch a NameError and
someModulo = 6%2
print "baby let's go"
someInt = 2+2
print "someInt is: ", someInt
# copy and paste the following into IDLE, which on my machine often
#crashes for an unknown reason, so I've taken to creating a harness that
#imports the required library and then runs the desired programs to test
#the desired behavior
if __name__ == "__main__":
print "encountered error"
but I get the following error:
SyntaxError: 'continue' not properly in loop
What am I doing wrong ?
More information about the Tutor