Static Typing in Python

Peter Hickman peter at semantico.com
Mon Mar 15 16:26:58 CET 2004


Jacek Generowicz wrote:
> Peter Hickman <peter at semantico.com> writes:
>>Premshree Pillai wrote:
>>>Like in C, C++, etc, Python too is
>>>strongly typed, i.e., variables are necessarily bound
>>>to a particular type.

[deletia]

> Secondly, you appear to be confusing C and C++ with strongly typed
> languages. A common mistake :-)

No I was just taking Premshree's lead where he says 'Like in C, C++, 
etc, Python too is strongly typed'

> Python is strongly typed because:
> 
> - lots of type checking is done
> - few implicit type conversions are done.
> - No operations which are inappropriate to the object(s) in question
>   are allowed.

Perhaps you should read the following 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."

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.

"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."

Here's the link http://www.artima.com/intv/strongweakP.html I would 
recommend reading www.artima.com to anyone interested in programming.

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

1-0



More information about the Python-list mailing list