Python style: to check or not to check args and data members
paddy3118 at netscape.net
Sat Sep 2 00:46:53 CEST 2006
Joel Hedlund wrote:
> > You might try doctests, they can be easier to write and fit into the
> > unit test framework if needed.
> While I firmly believe in keeping docs up to date, I don't think that
> doctests alone can solve the problem of maintaining data integrity in
> projects with more comlex interfaces (which is what I really meant to
> talk about. Sorry if my simplified examples led you to believe
> otherwise). For simple, deterministic functions like math.pow I think
> it's great, but for something like BaseHTTPServer... probably not. The
> __doc__'s required would be truly fascinating to behold. And probably
> voluminous and mostly unreadable for humans. Or is there something that
> I've misunderstood?
Oh, I was just addressing your bit about not knowing unit tests.
Doctests can be quicker to put together and have only a small learning
On the larger scale, I too advocate extensive checking of 'tainted'
data from 'external' sources, then assuming 'clean' data is as expected
and doing no explicit further data checks, after all, you've got to
trust your development team/yourself.
More information about the Python-list