try..catch..finally?

Irmen de Jong irmen at NOSPAMREMOVETHISxs4all.nl
Thu Jul 11 14:46:56 EDT 2002


Is there a reason why the finally clause cannot be used with the catch and 
else clauses?

I'd rather write

   try:
     print 1/0
   except:
     print 'oops!'
   finally:
     print 'afterwards'


instead of:

   try:
     try:
       print 1/0
     except:
       print 'oops!'
   finally:
     print 'afterwards'


It's no big problem really, one extra try block, but I'm just curious why
this is the case.

Irmen de Jong.

	




More information about the Python-list mailing list