Custom exceptions -- inherit from exceptions.Exception?
Martin v. Löwis
martin at v.loewis.de
Wed Nov 12 02:18:14 EST 2003
pwmiller1 at adelphia.net (Paul Miller) writes:
> where NotEnoughPlayers is really just an empty classic class suitable
> for raising. Is there any benefit to importing exceptions and
> inheriting from exceptions.Exception, other than maybe theoretical
> purity?
The idea is that, eventually, you can replace
except:
with
except Exception:
with the additional advantage of being able to write
except Exception,e:
Python does not yet enforce exception to inherit from Exception,
but it might some day, at which point you don't have to change
your code.
Regards,
Martin
More information about the Python-list
mailing list