Abuse of the object-nature of functions?
Ant
antroy at gmail.com
Tue Jul 11 16:07:41 EDT 2006
> > 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.
Ignoring the fact you haven't re-raised the exception (as we can ignore
the fact mine doesn't handle the others ;-) ), it does show a different
valid approach: mine has an advantage if the exceptions you don't want
to handle inherit from a small number of base classes; yours has the
advantage if there are a large number of unrelated exceptions that need
ignoring.
More information about the Python-list
mailing list