static, dynamic, strong and weak (was RE: PEP 285: Adding a bool type)

Alex Martelli aleax at aleax.it
Wed Apr 10 06:34:22 EDT 2002


Ken Seehof wrote:
        ...
> as a float, int, longint, or bool, depending on context.  All numbers
> of equal value are pretty much interchangable (this becomes more true
> as we add more numeric unification features).  In c/c++ numbers are
> more strongly typed, in that there are many ways to get error messages
> for using the wrong type of number without explicit conversion.

I disagree.  For example, in C I can use a float to index into an
array and get it converted to an int implicitly and silently; in
Python, using a float to index into a list is a TypeError.  What
kind of compensating examples do you have in mind, where C would
be stricter than Python "for using the wrong type of number"?


> The fact that an object's type doesn't actually change seems like an
> implementation detail to me.  Numbers in python -feel- as if they are
> weakly typed.

Not to me.  Even in Haskell I can write 1+2.0 - and Haskell is the
strongest-typed and feeling-strongest-typed GOOD language I know
(let's PLEASE forget that unnamed language where you must use + only
to add integers and +. to add floats... have they changed it yet?-).

The first time I (accidentally) used a float as a list index and
got a TypeError has impressed Python on me as strongly (albeit dynamically)
typed, better than any other study or experience so far.


Alex




More information about the Python-list mailing list