Clarity vs. code reuse/generality

Jean-Michel Pichavant jeanmichel at
Fri Jul 10 05:11:33 EDT 2009

Nobody wrote:
> On Thu, 09 Jul 2009 04:57:15 -0300, Gabriel Genellina wrote:
>> Nobody says you shouldn't check your data. Only that "assert" is not the  
>> right way to do that.
> "assert" is not the right way to check your *inputs*. It's a perfectly
> reasonable way to check data which "should" be valid, as well as a way to
> document what variables are supposed to contain.
Maybe, one of the assert problem is a semantic issue. Assert is a 
convenient way to write in the code "This is a requirement, get lost if 
you don't fit in". However it seems we often forget that builtin asserts 
can be disabled.
One possible solution for those who prefer to write assertions instead a 
'if A then Exception' is to write their own assertion statement and 
**raise an exception** that will not be disabled at runtime.


More information about the Python-list mailing list