global exception catching

user at domain.invalid user at domain.invalid
Thu Feb 27 02:19:18 EST 2003


This may be overly simplified, but anyway, is there a reason
for no putting all your code inside a "try" clause? Something like
   try:
     do this,
     created that file,
     etc,
     .
     .
     .
   exception ExceptionType1:
     do something,etc
   .
   .
   .
   exception ExceptionTypen:
     do something else,etc
   .
   .
   .
   exception:
     handle unexpectd (general) exceptions


Hilbert wrote:
> Hello,
> 
> Is there a way to catch a "global" exception in a python
> program (meaning that if there would be an error
> during execution it could call a function before exiting)?
> 
> I have a program that creates large temp files and in case
> of any unforseen problems I still need to clean up before
> exiting.
> 
> 
> Thanks,
> Hilbert
> 
> 
> 





More information about the Python-list mailing list