strong/weak typing and pointers

Andrea Griffini agriff at tin.it
Thu Oct 28 14:54:10 EDT 2004


On Thu, 28 Oct 2004 18:34:12 +0200, "Diez B. Roggisch"
<deetsNOSPAM at web.de> wrote:

>> Is it correct to say that strong/weak typing does not make a difference
>> if one does not use any pointers (or adress-taking operator)?
>
>It seems that you mistake strong/weak typing with static/dynamic typing - a
>completely different beast.
>
>Python is in fact strong typed - in opposition to php or perl or even C,
>this won't work:
>
>a = "1" + 2
>
>as "1" is a string and 2 an integer. And even though C is statically typed,
>it won't complain - you just end up with an unexpected result.

You didn't mention C++. Try this ...

   std::string s = "Wow";
   s += 3.141592654; // Perfectly valid
   s = 3.141592654;  // Also valid

Andrea



More information about the Python-list mailing list