On 2006-08-28, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> On 2006-08-25, Simon Forman <[EMAIL PROTECTED]> wrote: >>> ... >>> Generally asserts should be used to "enforce" invariants of your code >>> (as opposed to typechecking), or to check certain things while >>> debugging. >> >> I don't understand this argument. Can't type checking be seen as >> enforcing a code invariant? >> > But it is practically never the "right" invariant.
And who decides what is and what is not the "right" invariant? > You don't usually > mean type(x) == int, but rather something like x is a prime between 2 > and 923. Or 5< x**4 < 429, or _something_ problem specific. saying > that x must be an int is almost always simultaneously too specific and > too general. There seem to be enough problems that work with ints but not with floats. In such a case enforcing that the number you work with is indeed an int seems fully appropiate. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list