Static Typing in Python

Jacek Generowicz jacek.generowicz at cern.ch
Mon Mar 15 10:59:04 EST 2004


Peter Hickman <peter at semantico.com> writes:

> Perhaps you should read the following

I have read it before. I still disagree with the implication that
Python is weakly typed just much as I did when I first read it.

But you are ignoring my explanation of how Python is strongly typed,
and of the distinction between strong-vs-weak and dynamic-vs-static
typing, and are instead resorting to argument from authority:

> where Guido van Rossum talks about typing in Python. Here he is
> contrasting strongly typed languages with Python.
> 
> "In a strongly typed language, when you change to a different data
> structure, you will likely have to change the argument and return
> types of many methods that just pass these things on. You may also
> have to change the number of arguments, because suddenly you pass the
> information as two or three parts instead of one. In Python, if you
> change the type of something, most likely pieces of code that only
> pass that something around and don't use it directly don't have to
> change at all."

He's actually contrasting _statically_ typed languages with
Python. Unfortunately he is using the word "strongly" where he should
be using "statically".

If you actually _think_ about what he is saying, rather than being
satisfied with finding words which appear to confirm your
misconceptions, then you should be able to see that he is really
talking about _statically_ typed languages.

> It would seem to be clear that what Guido considers to be strong
> typing is not a feature of Python. As the following quote seems to
> indicate.

I wonder how you reach that conclusion ...

> "Weak typing is not really a fair description of what's going on in
> Python. It's really runtime typing because every object is labeled
> with a type."

... he seems to be suggesting that Python is NOT weakly typed ... so
the implication seems to be that it IS strongly typed. What he's
really hinting at is the fact that weak-vs-strong and
static-vs-dynamic are orthogonal axes.

(Hint: "runtime typing" is almost synonymous with "dynamic typing".)

> So there we have it, Python is *NOT* strongly typed unless you know
> more about Python than Guido van Rossum.

What an absurd statement. You are suggesting that Python's type system
somehow depends on the relative magnitudes of two people's knowledge.

I certainly don't know more about Python than Guido does, but I do
appear to know more about type system nomenclature than Guido does :-)

(I don't actually believe that. I believe that Guido used the words he
did because he was aware that a majority of people think that
static=strong and dynamic=weak.)

Argument from authority is remains very unconvincing, even if that
authority is Guido himself.



More information about the Python-list mailing list