Static Typing in Python
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Tue Mar 16 05:12:33 EST 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
>>>> 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?
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.
Bruno
More information about the Python-list
mailing list