Efficient python programming...

Kragen Sitaker kragen at pobox.com
Sun Jun 9 03:42:40 CEST 2002

Peter Hansen <peter at engcorp.com> writes:
> You forgot the even more important first thing for a beginner: 
> get it correct!  The only good way to do this is to write unit
> tests that prove it.  If you don't have tests, you don't have 
> working code (or how can you prove it?).

I agree that correctness is important, although I think it is
sometimes overemphasized; buggy programs can still be useful.  (I hate
them, though.)  For example, in the ICFP programming contests, any
entry found to contain a bug, however small, is automatically

I also agree that unit tests are very useful for reducing bugginess.

But I do not think that they are either necessary or sufficient for
writing correct code.  I think (and extensive experimentation has
shown) that careful reasoning and code reviewing is necessary and
sufficient to write correct code.

It is certainly possible to err too far in the direction of believing
your code correct simply because it passes its test suite, and this is
a common beginner's error.  I think it is also possible to err too far
in the direction of writing and running tests instead of desk-checking

More information about the Python-list mailing list