Clarity vs. code reuse/generality

kj no.email at please.post
Sat Jul 4 17:13:23 EDT 2009


In <7xzlbkti7z.fsf at ruckus.brouhaha.com> Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:

>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.

Precisely.  As I've stated elsewhere, this is an internal helper
function, to be called only a few times under very well-specified
conditions.  The assert statements checks that these conditions
are as intended.  I.e. they are checks against the module writer's
programming errors.



More information about the Python-list mailing list