Clarity vs. code reuse/generality

kj no.email at please.post
Sat Jul 4 17:14:45 EDT 2009


In <mailman.2621.1246733010.8015.python-list at python.org> MRAB <python at mrabarnett.plus.com> writes:

>Paul Rubin wrote:
>> kj <no.email at please.post> writes:
>>> This implies that code that uses *any* assert statement (other than
>>> perhaps the trivial and meaningless ones like "assert True") is
>>> liable to break, because whatever it is that these assert statements
>>> are checking "on some occasions, ... would go unchecked, potentially
>>> breaking your code."
>> 
>> Yes, that implication is absolutely valid.  The purpose of assert
>> statements is to debug the code, by checking for conditions that are
>> supposed to be impossible.  Unless the program is broken (i.e.  the
>> impossible happened), no assert statement should ever trigger.
>> 
>Technically these are known as "invariants". An assertion will always be
>True if the program is bug-free, no matter what the user might throw at
>it; it's not the same as validation.

What *user* are you talking about???  I've stated a bazillion times
that this function is meant to be called only from within this
module.




More information about the Python-list mailing list