Error checking in Python
donn at drizzle.com
Tue Jun 10 09:06:08 CEST 2003
Quoth BGM <no.spam at comcast.net>:
| A certain aspect of the replies interests me greatly: That if one does no
| type-checking, the function lends itself to previously unforseen
| generalization.... E.g. if the function were meant to multiply some
| number by 2: x = x * 2 in which case that is also valid even if x is a
| string! I wonder whether this phenomena is found to be useful in practice?
| Does anyone know?
Well, no - at least, probably no one is going to be able to give
you a quick answer to that one here. My impression is that the
range of generalization suggested by your example is rarely very
On the other hand, there are a couple of string types, and that
range of generalization is clearly going to be useful - the same
function should work with strings and Unicode strings. Likewise
for a couple of numeric types, sequences, etc.
Donn Cave, donn at drizzle.com
More information about the Python-list