Error checking in Python

Donn Cave donn at
Tue Jun 10 09:06:08 CEST 2003

Quoth BGM <no.spam at>:
| 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

More information about the Python-list mailing list