Static Typing in Python

Premshree Pillai premshree_python at
Tue Mar 16 13:54:46 CET 2004

 --- Peter Hickman <peter at> wrote: >
Premshree Pillai wrote:
> >  --- Peter Hickman <peter at> wrote: >
> > Premshree Pillai wrote:
> >>>Like in C, C++, etc, Python too is
> >>>strongly typed, i.e., variables are necessarily
> >>
> >>bound
> >>
> >>>to a particular type.
> [deletia]
> > The above returns a TypeError in Python, but not
> in
> > PHP, which is weakly typed.
> > 
> > Get it?
> The only two (or perhaps one and a half) languages
> you used as reference 
> were C and C++. Which you said 'Like in C, C++, etc,
> Python too is 
> strongly typed'. What has PHP got to do with it? How
> does PHP's typing 
> have anything to do with Python's?
> Typing in C and C++ is different to Python.
> int c = 0;
> c = "fred";
> No can do in C and C++.
> c = 0
> c = "fred"
> No problem in Python.
> So just how is Python strongly typed 'like in C,
> C++, etc'?
> -- 

I said it in an earlier post, and I'll say again: I
never said strong typing is about being able to change
the type of a variable; I said that strong typing
means that a variable is necessarily bound to a
specific type; this is true for C and C++ too (both
are strongly typed). PHP is weakly typed; variables
are not bound to a specific data type. For e.g., I can
do the following in PHP:

// PHP snippet
str = "xyz";
t = str + 0 // this is not an error in PHP

On the other hand, Python will return an error when
you try to add a string to an integer; PHP won't.

-Premshree Pillai


Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more. 
Go to:

More information about the Python-list mailing list