Returning to 'try' block after catching an exception

Terry Reedy tjreedy at udel.edu
Wed May 21 19:42:28 EDT 2008


"Karlo Lozovina" <_karlo_ at _mosor.net_> wrote in message 
news:Xns9AA6FDC59536mosornet at 161.53.160.65...
| André <andre.roberge at gmail.com> wrote in
| news:a9913f2d-0c1a-4492-bf58-5c78813c4458 at s50g2000hsb.googlegroups.com:
|
| > How about something like the following (untested)
| >
| > done = False
| > while not done:
| >   try:
| >      some_function()
| >      done = True
| >   except:
| >      some_function2()
| >      some_function3()
|
| Sure, that works, but I was aiming for something more elegant and 
Pythonic
| ;).

while True:
  try:
    some_function()
    break
  except Exception:
    patchup()

??? 






More information about the Python-list mailing list