On Wed, Aug 22, 2012 at 11:46 AM, lipska the kat
<lipskathe...@yahoo.co.uk> wrote:
> If, in a language, I find I am able to say
>
> a = 1
>
> then later, in the same scope I can say
>
> a = "foo"
>
> then later again in the same scope I can say
>
> a = ([1,2,3], "xyz", True)
>
> then, and I may be missing something here, to me, that doesn't say 'strongly
> typed' that says 'no typing constraints whatsoever'

You're conflating "strong typing" with "static typing".  Strong typing
does not refer to restrictions on what type of data can be stored
where, but to restrictions on how operations on that data can be
intermixed.

The classic example of weak typing is concatenation of strings and
numbers, e.g. ("abc" + 123).  Weakly typed languages like JavaScript
will implicitly coerce the number to a string and perform the
concatenation.  Strongly typed languages like Python will raise a
TypeError instead.

Note that statically typed languages can be weakly typed as well.  For
instance, C is commonly considered to be weakly typed because the
casting rules of that language allow you to treat any piece of data as
being of any type, even though the variables themselves are all
statically typed.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to