try catch - If exception retry in Python -


how go doing this

  1. try something.
  2. if works, great, continue normal flow.
  3. if fails run function , try again.
  4. if once again fails throw exception , stop code.

i believe have make use of try haven't quite come around yet how use in particular example.

try nested try catch:

try:     do_something() #if works, skip rest , continue except:     do_fix_function() #on error, function     try:         do_something() #try again     except:         throw error() #if fails time, stop , throw error 

note if do_fix_function() can fail, might want put inside second try statement instead


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -