Static Typing in Python

Jacek Generowicz jacek.generowicz at cern.ch
Mon Mar 15 03:44:50 EST 2004


Dang Griffith <google0 at lazytwinacres.net> writes:

> >Not forcing variable initialization does have its problems. Here's
> >what I mean:
> >http://www.livejournal.com/users/premshree/10624.html?thread=53376#t53376
> 
> 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.

It's just one of the thousands of possible styles of bugs that you can
introduce into the program ... ALL of which will be caught by a decent
test suite. Adding restrictions to a language just to catch one of the
many of styles of possible bugs is counterproductive. Support your
development with a decent test suite, and use the most flexible
language you can get your hands on.



More information about the Python-list mailing list