When to use assert

Chris Angelico rosuav at gmail.com
Sun Oct 26 10:51:19 CET 2014

On Sun, Oct 26, 2014 at 8:39 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> In the absence of correctness proofs for your code, anything you do (unit
> tests, assertions, regression tests, etc.) is just a statistically sampling
> of all the potential paths your code might take, hoping to capture bugs. As
> any statistician will tell you, eventually you will reach the point of
> diminishing returns, where adding more samples isn't worth the cost. That
> point will depend on the cost in programmer effort, the performance
> implications, and your confidence in the code.

That's about the size of it, I guess. How much testing versus how much
time actually spent coding?

I'm pretty sure a lot of my code has the wrong ratio... I'm just not
sure, for a lot of the code, which direction it's wrong :)


More information about the Python-list mailing list