Adding static typing to Python

Steve Holden sholden at holdenweb.com
Wed Feb 20 08:14:02 EST 2002


"Magnus Lyckå" <magnus at thinkware.se> wrote ...
> ajeru at vknn.org (Alexander Jerusalem) wrote ...
> > The argument that exhaustive testing should be done anyway is
> > certainly true. I nevertheless tend to think that it's better to let
> > the compiler do as much as possible in terms of error checking and
> > then use testing to find the true runtime errors. It just takes much
> > less time than starting a test run every time just to find all my
> > typos. I don't know if there are test suites that let you run all the
> > branches of all your methods and show you all typos at a time. I
> > suspect that I'd have to start the test suite for each and every typo
> > but I'm not knowledgable enough when it comes to Python test suites to
> > be sure of that claim.
>
I'm not sure I'd agree with that, given that Python is fairly good at only
compiling what needs to be recompiled. I can agree it will be something of a
problem for long batch jobs. Before you do such integration testing,
however, your unit tests, which are almost always lightweight, should have
pulled any syntax errors and name typos.

> I'm trying to adopt the XP habit of writing tests first, and then
> only code enough to make the test pass. It's sometimes difficult.
> It requires some diciplin not to get carried away while writing the
> code, and do more than I've written tests for. When I do get carried
> away I end up having to write a whole bunch of boring tests afterwards,
> and that feels like a drag, because then the writing of tests is not
> part of the creative process. And it's difficult to be sure that I
> actually have all the tests I need then.
>
As far as this goes, EITHER you aren't being sufficiently rigorous in
defining your tests, OR you are over-specifying unnecessarily during
implementation. This latter is a particularly troublesome waste of
programmer time, which XP attempts to eliminate with its well-known (?) "You
aren't gonna need it" credo:

    http://c2.com/cgi/wiki?YouArentGonnaNeedIt

In other words, when you find yourself thinking "Wow, this frobnicator could
also uglify with only ten extra lines of code", you can most often save
yourself the ten extra lines of effort until the customer demands
uglification :-0

[...]
regards
 Steve
--
Consulting, training, speaking: http://www.holdenweb.com/
Author, Python Web Programming: http://pydish.holdenweb.com/pwp/

"This is Python.  We don't care much about theory, except where it
intersects with useful practice."  Aahz Maruch on c.l.py







More information about the Python-list mailing list