Static Typing in Python

Peter Hickman peter at semantico.com
Mon Mar 15 07:52:46 EST 2004


Premshree Pillai wrote:
> Like in C, C++, etc, Python too is
> strongly typed, i.e., variables are necessarily bound
> to a particular type.

Python 1.5.2 (#1, Jan 31 2003, 11:01:49)  [GCC 2.96 20000731 (Red Hat 
Linux 7.2 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
 >>> a = 1
 >>> a
1
 >>> a = "fred"
 >>> a
'fred'
 >>> a = open
 >>> a
<built-in function open>
 >>>

So here was have a variable 'a'. In the first instance I set it to a 
number. Then I set it to a string. Now in a strongly typed language, 
such as C or C++, would be screaming that "fred" was not an integer. 
Then we set it to, in effect, a pointer to a function. Again no error.

Could you please clarify how this consitutes Python being 'strongly typed'?



More information about the Python-list mailing list