Slight irritation with try/finally indentation

Jeff Shannon jeff at ccvcorp.com
Mon May 6 14:12:38 EDT 2002


In article <Xns92067999CBF19jimpublishingresourc at 209.249.90.101>, 
Jim Abrams says...
> pinard at iro.umontreal.ca (François Pinard) wrote in
> news:mailman.1019657853.14965.python-list at python.org: 
> > 
> >     [...]
> >     setup()
> >     try:
> >         process()
> >     finally:
> >         cleanup()
> >     [...]
> 
> setup()
> 
> try:
>     	process() 
> except: # or other exception handling
>     	pass
> 
> cleanup()

Doesn't work, because the exception handling may wish to 
terminate the program, or at least return from the current 
execution frame, and in that case, cleanup() will not be called.  
(Which may be important for closing database connections, 
removing temp files, etc.)

-- 

Jeff Shannon
Technician/Programmer
Credit International



More information about the Python-list mailing list