To view parent comment, click here.
To read all comments associated with this story, please click here.
Then why does the second page of what you linked explicitly say it's not weak typing? Why does Wikipedia's page say Python is strongly typed? Why do all of c2's pages on typing say Python is strongly typed?
No, I'm afraid you're wrong. Python is strongly typed. It's just checked at runtime.
How would most type systems fail to classify a cat properly?
data FurType = Short | Long | Medium
data Color = Black | Orange | White | Tabby | ...
data Cat = Cat { hungry :: Bool, fur :: FurType, color :: Color, ... }
mycat = Cat True Short Black ...
It isn't that cat's are hard to design a strong model for. It's that there's no point in doing it because it's irrelevant. The following is just as sufficient for this.
(True,"short","black",...)
Easy enough to check:
"Weak typing is not really a fair description of what's going on in Python."
Which is fair given that Python uses types for implementation reuse and error reporting. This of course doesn't stop me from adding a method "bark()" to an existing class "cat".
It also says that Lisp is strongly typed (a language specifically designed for making all non-primitive values untyped). The reason they give is that it doesn't do type coercion, which is IMHO a stupid way of defining "strong typing". But I will accept that, so if you wish, we may end the discussion here.
data FurType = Short | Long | Medium
data Color = Black | Orange | White | Tabby | ...
data Cat = Cat { hungry :: Bool, fur :: FurType, color :: Color, ... }
mycat = Cat True Short Black ...
Interesting (really!). But note that Haskell's type system is definitely not what people would call "most type systems".
And even Haskell can't make a "cat" object sometimes hungry, sometimes not. (True, this goes deeper than the type system in Haskell).





Member since:
2009-06-30
The "cat" example was simple object yet most type systems would fail to classify it properly. Real objects have multiple "types" in many hierarchies, often changing over time.
As for python - there was never any debate about it. It has always been a weakly typed language by most definitions (admittedly, not yours). In fact, Guido had to often defend his choice against legions of people who prefer strong typing:
http://www.artima.com/intv/strongweak.html