OT: This Swift thing

Sturla Molden sturla.molden at gmail.com
Thu Jun 5 19:08:19 EDT 2014


Chris Angelico <rosuav at gmail.com> wrote:

> "Type safety" means many different things to different people. What
> Python has is untyped variables, and hierarchically typed objects.
> It's impossible to accidentally treat an integer as a float, and have
> junk data [1]. It's impossible to accidentally call a base class's
> method when you ought to have called the overriding method in the
> subclass, which is a risk in C++ [2]. 

Exactly.

I have no hopes that those who claim Python lacks type safety will
understand this, however.


> If you mistakenly pass a list to
> a function that was expecting an integer, that function will *know*
> that it got a list, because objects in Python are rigidly typed.
  
And then there is nothing that prevents the function from raising a
TypeError.


Sturla




More information about the Python-list mailing list