Callable assertion?

Terry Reedy tjreedy at udel.edu
Sun Oct 5 22:16:53 EDT 2003


"Roy Smith" <roy at panix.com> wrote in message
news:roy-408A7D.18354005102003 at reader2.panix.com...
> There's a big difference between verifying that a passed parameter
has
> the properties it's supposed to have and trying to figure out if you
can
> read a file or open a socket.

Readability and connectability are also possible properties of passed
parameters.  For your purpose of init-time checking, the relevant
property of properties is whether the property can be satifactorily
checked at init time or not.

> The former catches a programming error.  If I meant to pass fred and
I
> pass fred() by mistake, the problem is going to be there every time
I
> run the program until I fix the code.

And if you pass the name of an access prohibited file, that error will
also continue until fixed.

Alex Martelli has written several pages on 'look before you leap' (his
phrase) versus 'try and respond to failure' (not his).  Look them up
for more discussion of this topic.

Terry J. Reedy






More information about the Python-list mailing list