[Tutor] pausing time and perform on exit
alan.gauld@bt.com
alan.gauld@bt.com
Sun Nov 3 18:35:02 2002
Kyle,
I think you are getting too complex which might mean you're using
the wrong appproach? Since I don't know exactly what/why your
doing this stuff I can only suggest an alternative approach
without knowing if its suitable...
try:
# your code here
# exit using exit_f1()
raise exit1
# more code here
# exit with other func
raise exit2
except exit1:
exit_f1()
except exit2:
exit_f2()
except SystemExit: # default from sys.exit...
exit_default()
Would that work better?
You could even make the raised exception be 'constant by storing
the exception class in a variable:
try:
exception_type = exit1
# do stuff
raise exception_type
# do more
exception_type = exit2
raise exception_type
except:....
That might be better if you raise the exit within a loop or function
and don't know the exit state until you enter the loop etc...
Just an idea...
Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld