Newbie: use of built-in exceptions

R

Rui Maciel

Are there any guidelines on the use (and abuse) of Python's built-in exceptions, telling where
it's ok to raise them and where it's preferable to define custom exceptions instead?


Thanks in advance,
Rui Maciel
 
C

Chris “Kwpolska†Warrick

Are there any guidelines on the use (and abuse) of Python's built-in exceptions, telling where
it's ok to raise them and where it's preferable to define custom exceptions instead?

There are no rules. You should use common sense instead: if the
exception fits your needs (eg. ValueError when incorrect output
occurs) then use it.
 
R

Rui Maciel

Chris said:
There are no rules. You should use common sense instead: if the
exception fits your needs (eg. ValueError when incorrect output
occurs) then use it.

Ok, thanks for the tip.


Rui Maciel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top