Abuse of the object-nature of functions?

Simon Forman rogue_pedro at yahoo.com
Tue Jul 11 15:50:15 EDT 2006


Simon Forman wrote:
> Carl J. Van Arsdall wrote:
> > Hrmms, well, here's an interesting situation.  So say we wanna catch
> > most exceptions but we don't necessarily know what they are going to
> > be.  For example, I have a framework that executes modules (python
> > functions), the framework wraps each function execution in a try/except
> > block in order to compensate for what *might* happen.  Upon coding the
> > framework I really have no idea what types of problems these modules
> > might have but I want to catch these errors so that I can clean up and
> > exit gracefully, not only that but I want to dump the exception to log
> > files so that we can attempt to fix it.  So, I have the option of
> > catching all standard exceptions and not list the ones I know I don't
> > want to catch.  But what about user defined exceptions?  Do I then have
> > to enforce policies on the system stating what types of exceptions can
> > be raised?
> >
> > Is there a way in python to say, "hey, catch everything but these two"?
> >
> >
> >
> > --
> >
> > Carl J. Van Arsdall
> > cvanarsdall at mvista.com
> > Build and Release
> > MontaVista Software
>
>
> try:
>     # Do some stuff
> except Exception, err:
>     if err not in (DontCatchMe1, DontCatchMe2):
>         # Handle err
>
> HTH,
> ~Simon

Dang!  not only did somebody else beat me to it, but my code is wrong
and theirs correct.

Sorry,
~Simon




More information about the Python-list mailing list