"no variable or argument declarations are necessary."

Antoon Pardon apardon at forel.vub.ac.be
Tue Oct 4 09:35:07 CEST 2005

Op 2005-10-03, Steven D'Aprano schreef <steve at REMOVETHIScyber.com.au>:
> On Mon, 03 Oct 2005 06:59:04 +0000, Antoon Pardon wrote:
>> Well I'm a bit getting sick of those references to standard idioms.
>> There are moments those standard idioms don't work, while the
>> gist of the OP's remark still stands like:
>>   egold = 0:
>>   while egold < 10:
>>     if test():
>>       ego1d = egold + 1
> for item in [x for x in xrange(10) if test()]:
> But it isn't about the idioms. It is about the trade-offs. Python allows
> you to do things that you can't do in other languages because you
> have much more flexibility than is possible with languages that
> require you to declare variables before using them. The cost is, some
> tiny subset of possible errors will not be caught by the compiler. But
> since the compiler can't catch all errors anyway, you need to test for
> errors and not rely on the compiler. No compiler will catch this error:
> x = 12.0 # feet
> # three pages of code
> y = 15.0 # metres
> # three more pages of code
> distance = x + y
> if distance < 27:
>     fire_retro_rockets()
> And lo, one multi-billion dollar Mars lander starts braking either too
> early or too late. Result: a new crater on Mars, named after the NASA
> employee who thought the compiler would catch errors.

Using (unit)tests will not guarantee that your programs is error free.

So if sooner or later a (unit)tested program causes a problem, will you
then argue that we should abondon tests, because tests won't catch
all errors.

Antoon Pardon

More information about the Python-list mailing list