Python Strings

Jonadab the Unsightly One jonadab at bright.net
Tue Sep 19 05:43:04 EDT 2000


Keith Ray <k_j_r_a_y at ix.netcom.com> wrote:

> What most people mean by "strongly-typed" or "staticly typed" is "there 
> is compile-time checking of variable types" (and parameter-types, and 
> function-return-types and expressions being assigned or passed into 
> variables/parameters/etc.).

When I think of "strongly typed" I think of Pascal, where it isn't
even theoretically possible[1] to write code that can accept either 
a number or a string as its first parameter and either a routine
or a string as its second parameter, for example.  You have to
know at compile time what kind of thing you're going to have,
and that's that.  

> What most people mean by "weakly-typed" or "dynamically typed" is "there 
> is only run-time checking of variable types" (and parameter-types, and 
> function-return-types and expressions being assigned or passed into 
> variables/parameters/etc.).

What I mean is, "there is only type-checking if the programmer
specifies it".  

> Python and Smalltalk are not staticly typed, because you don't declare 
> the types for variables, parameters, and function-return-values. You can 
> assign any type of object to a variable, and assign a completely 
> different type of object to the same variable in the next line, and the 
> compiler does not complain. If you pass a list into a function-parameter 
> where the function is expecting an floating-point-scalar, then you will 
> most likely have a run-time error.

This sounds roughly like the kind of typing I like.  Mostly.


[1]  Well, okay, you could write your own
     store-everything-as-a-string code...

- jonadab



More information about the Python-list mailing list