Is this the *right* way of exception handling?

Erik Max Francis max at alcyone.com
Fri Aug 3 20:18:31 EDT 2001


Quinn Dunkan wrote:

> Unfortunately, python's
> assertion mechanism is not well integrated with the exception
> mechanism, so
> assertions that should really raise a ValueError will always raise an
> AssertionError.  A possible third argument to 'assert'?

Are you suggesting some kind of difference between logic asserts (logic
faults) and data asserts (bad data, has to be handled properly)?  In
Python, the latter should definitely not be presented as asserts, but
rather as just raising some other (possibly custom) exception.  Logic
asserts mean something's broken; data asserts just means someone sent it
bad input data and need to be handled properly by the program in any
case.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ The basis of optimism is sheer terror.
\__/ Oscar Wilde
    Rules for Buh / http://www.alcyone.com/max/projects/cards/buh.html
 The official rules to the betting card game, Buh.



More information about the Python-list mailing list