P
Paul Miller
Is there any particular good reason to inherit from
exceptions.Exception? I've never seen any code that depends on what
the base class(es) of a raised exception is (are).
My use case is in a game I am writing. The code for my Game class
contains the following:
class Game (object):
def start (self):
try:
self.players[1]
except IndexError:
raise NotEnoughPlayers
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?
Thanks!
exceptions.Exception? I've never seen any code that depends on what
the base class(es) of a raised exception is (are).
My use case is in a game I am writing. The code for my Game class
contains the following:
class Game (object):
def start (self):
try:
self.players[1]
except IndexError:
raise NotEnoughPlayers
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?
Thanks!