Static Typing in Python
bdesth.quelquechose at free.quelquepart.fr
Tue Mar 16 11:12:33 CET 2004
Peter Hickman wrote:
> Premshree Pillai wrote:
>> --- Peter Hickman <peter at semantico.com> wrote: >
>> Premshree Pillai wrote:
>>>> Like in C, C++, etc, Python too is
>>>> strongly typed, i.e., variables are necessarily
>>>> to a particular type.
>> 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?
It has... Both are dynamically typed.
> Typing in C and C++ is different to Python.
> int c = 0;
> c = "fred";
> No can do in C and C++.
int c = (int)"fred";
> c = 0
> c = "fred"
> No problem in Python.
And then c + 4 will raise an exception.
> So just how is Python strongly typed 'like in C, C++, etc'?
You already had the answer -or at least part of- in this thread, but
braindeadly dismissed it.
More information about the Python-list