Steve Holden wrote: > > Some other functions rely on the AssertionError exception to indicate to > > the user that something went wrong instead of using a user defined > > exception. > > > > The real problem here is that you appear to be using AssertionError in > an inappropriate way. If some caller passes an incorrect argument to > your function, raise a ValueError. If you are passed the wrong type of > data, raise a TypeError. And so on. Or, as you imply you thought about, > raise a user-defined error. > > Generally speaking you should reserve assert for circumstances where you > expect some invariant condition to be true. Otherwise use an "if" > statement and raise some other exception if the condition is True. > What would be the occasion that AssertionError be the right exception to raise then ?
-- http://mail.python.org/mailman/listinfo/python-list