Mac Ryan wrote:

    raise BaseException('Something is wrong here!')

Never raise BaseException directly! BaseException is the very top of the exception hierarchy, you should raise the *most* specific exception you can, not the least specific. BaseException isn't even just for errors, it's also for flow control exceptions like StopIteration .

At worst, you should raise StandardError, but even that is a pretty dodgy thing to do. In general you want something more specific, like ValueError or TypeError. In this particular case, the appropriate error would be to raise RuntimeError: if you're ever in the position of having to just give up and say "I have no idea what is wrong, but something is wrong", then RuntimeError is the one to use.


More about exceptions here:

http://docs.python.org/library/exceptions.html


--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to