Static Typing in Python
google0 at lazytwinacres.net
Tue Mar 16 23:34:53 CET 2004
On Tue, 16 Mar 2004 02:28:15 +0000 (GMT), Premshree Pillai
<premshree_python at yahoo.co.in> wrote:
> --- Joe Mason <joe at notcharles.ca> wrote: > In article
><mailman.11.1079347355.12241.python-list at python.org>,
>> Premshree Pillai wrote:
>> > Err...you probably have the wrong idea of static
>> > typing, I think. Static typing has to do with
>> > declaration (initialization) of variables (and not
>> > variable types). Like in C, C++, etc, Python too
>> Is that an official definition from somewhere?
>> Cause I always thought
>> static typing was about variable types.
>Hmm...I might have been a little wrong there. However,
>what I wanted to stress was that it's the explicit
>declaration of the variable that matters (that makes
>static typing what it is).
Static typing does not have to do with explicit declaration.
As you said earlier, Perl has an option to force explicit
declaration, and yet Perl is not statically typed. Python function
arguments are explicitly declared, but are dynamically typed.
It seems you want the compiler to complain when a
previously unused/unnamed/undeclared variable is
used on the left side of an equation. (It already complains
for vars on the right side and in expressions.)
I think there is value in detecting such problems, but I
think there is enough evidence in existing Python code
that there is little value to having it *in the language
itself*. As other posters have pointed out, there are
other ways of detecting these problems, such as with
pychecker and PyRex.
I'm bowing out of this discussion. I hope I have been
somewhat helpful. The strong/weak/static/dynamic
discussion has gone on many times before, and I don't
see it as being particularly relevant to explicit declaration.
I'm pretty sure you have the answer to your question.
Python does not force, or even support, variable declaration.
If you want that, you'll need to look to one of the other
Best wishes in your endeavors,
--Daniel 'dang' Griffith
(Yes, I know Python supports variable/keyword arguments
to functions, which don't require explicit declaration...)
More information about the Python-list