exception handling in complex Python programs

Rafe rafesacks at gmail.com
Wed Aug 20 12:51:56 EDT 2008


On Aug 20, 12:47 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> Rafe wrote:
> > Again, this is probably too simple to help, but the only way to ignore
> > certain types of exceptions, as far as I know, is to catch them and
> > pass.
> > e.g. this ignores type errors...
>
> > try:
> >     somethingBad()
> > except TypeError, err:
> >     pass
> > except Exception, err:
> >     raise TypeError(err)
>
> so what kind of code are you writing where *type errors* are not
> considered programming errors?  (catching them and proceeding is one
> thing, but catching them and ignoring them?)
>
> I'd be really worried if I found that in a piece of source code I had to
> maintain.
>
> </F>

I'm not it was just the first exception that came to mind... It is
pretty rare that I would pass an exception in fact. Maybe as a last-
resort test in some cases.

- Rafe



More information about the Python-list mailing list