Static Typing in Python
google0 at lazytwinacres.net
Mon Mar 15 14:12:07 CET 2004
On 15 Mar 2004 09:44:50 +0100, Jacek Generowicz
<jacek.generowicz at cern.ch> wrote:
>Dang Griffith <google0 at lazytwinacres.net> writes:
>> >Not forcing variable initialization does have its problems. Here's
>> >what I mean:
>> Yes, I agree. That is one reason I like Python.
>> It has forced variable *initialization*. You cannot use a variable
>> that has not been initialized.
>But there is nothing to prevent you from assigning to a previously
>non-existing variable, which is what Premshree is concerned about.
>> In fact, the act of initializing a variable is what makes the
>> variable exist.
>Exactly, make a typo, and the compiler won't notice.
>This can indeed be a minor annoyance in interactive
>exploration. However, the development of a real program, backed by a
>test suite, will catch the problem in no time.
Ironically, the error in the code that Premshree referenced, once
fixed for Python syntax, get in an infinite loop. So, a test suite
will not catch the problem, because the test will never finish.
But obviously, if one is using test-driven development, it should
be pretty clear which code has a problem.
More information about the Python-list