[Tutor] another question ( unrelated )

Kent Johnson kent37 at tds.net
Fri Jul 20 19:08:21 CEST 2007


shawn bright wrote:
> ok, how would i have it re-initialize itself ?
> 
> yes, i want to do this on a failure condition.
> something wrapped in a try - except

Nothing magic, it's just code. Something like this:

def run(self):
   while 1:
     # (re)initialization code goes here
     while 1:
       try:
         # do some real work here, repeatedly
       except:
         # oops. any error recovery goes here
         break # break out of the inner loop to repeat the init code
               # and restart the inner loop

Kent


More information about the Tutor mailing list