[Python-3000] i guess i was misunderstood
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri May 12 01:56:53 CEST 2006
tomer filiba wrote:
> b=B() # error, A.__init__ expects an instanc of A
>
> why is this kind of type-checking enforced by the language?
Since type-class unification, there is no clear boundary
between built-in and user-defined classes. Any class can
potentially add C-level data to its instances and have
methods implemented in C that operate on it. If you were
allowed to pass any object to any method, there would
be a danger of crashing the interpreter.
> what this code does is basically changing the __mro__ of the object. had
> __mro__ been mutable, it would all be simpler.
Being able to change the mro after class creation would
lead to similar problems.
--
Greg
More information about the Python-3000
mailing list