Proposal: runtime validation statement

Paul Rubin http
Mon Jul 12 20:45:50 EDT 2004


"F. GEIGER" <f.geiger at vol.at> writes:
> I use assert to protect my software from me, i.e. to catch programming
> errors, e.g. to catch cases where I called a method the wrong way. If
> this can happen under production consitions too, then it's a user
> error, not a programming error.
> 
> So, I use raise to protect my software from user errors.

But I write a lot of code for my own use, which means the user and the
programmer are the same person, and any user error is also a
programming error.  Lots of times also, the data came from some other
part of the program, so if the data is invalid, that's still a
programming error.

> Your sample seems to be a case of the latter, i.e. you have to write
> some sort of exception handling anyway. Issuing an error message
> anywhere in your code might not be what you really want.

If you want to keep running after an AssertionError, you have to handle
that too, but that doesn't make the assert statement useless.



More information about the Python-list mailing list