Static Typing in Python

JCM joshway_without_spam at myway.com
Wed Mar 17 20:53:16 EST 2004


Jacek Generowicz <jacek.generowicz at cern.ch> wrote:
> JCM <joshway_without_spam at myway.com> writes:

>> Jacek Generowicz <jacek at lxplus057.cern.ch> wrote:

>> which implies "weak typing" means there's the possibility of treating
>> a piece of data as the wrong type.

> Yes, consider

>    "3" + 3

> In languages that do not consider the above to be an error, you will
> probably get "33" or 6 as the result. Whether one of those pieces of
> data is treated as the wrong type or not, depends on your intentions.

I was unclear.  By treating a piece of data as the wrong type I meant
interpreting the actual bits as they weren't intended.  For example,
somehow being able to get the int value 13107 as a result of "3" + 3
because of wrongly interpreting the adjacent ascii char values as an
int ("3" + 3 => "33" => 255*51 + 51 => 13107).  Such a thing would not
be possible in a strongly typed language, by the definition I was
using.  But you're right--since this is really a discussion about
terminology, it's really not all that interesting :)



More information about the Python-list mailing list