Python types

Diez B. Roggisch deets at
Fri Mar 24 21:36:18 CET 2006

Steve M schrieb:
> I think it means that names, not objects, are weakly typed. So you can
> have:
> a = 4
> a = 'hello'
> and there is no problem. The name 'a' doesn't have any type associated
> with it. This contrasts with strongly typed language like C where you
> declare the type of the name (variable) and the compiler objects at
> compile time if you attempt to assign a value of a different type.

void foo() {
   int *c = "hello weakly typed C!";

192:/tmp deets$ gcc -c test.c
test.c: In function `foo':
test.c:5: warning: initialization from incompatible pointer type

So I wouldn't call C strongly typed....

The distinction is usually made on two axis: strong-weak and 
static-dynamic. Python is a strong-typed, dynamic language. JAVA is 
strong-typed static. And PHP is weakly-typed dynamic.



More information about the Python-list mailing list