Ant wrote: >> > 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.
His code is wrong since "err" is not the exception class but an instance. "if type(err) ..." would be correct but unpythonic. Georg -- http://mail.python.org/mailman/listinfo/python-list