[Python-3000] ABC PEP isinstance issue Was: PEP 31XX: A Type Hierarchy for Numbers (and other algebraic entities)
Jim Jewett
jimjjewett at gmail.com
Sun Apr 29 17:40:52 CEST 2007
On 4/28/07, Calvin Spealman <ironfroggy at gmail.com> wrote:
> I'm just going to jump into this and voice a concern that allowing
> overriding of isinstance and issubclass seems like a Bad Idea.
I'm also uncomfortable, which is why I originally suggested a parallel
predicate. That said, I can't put my finger on why it is wrong, so
I'm not certain that a parallel predicate (isa?) would be better.
Guido wrote:
> Note though that only the second argument to either function can
> overload the rules. IOW if you write isinstance(x, C), there is no way
> that x could attempt to lie; but C could.
As Barry pointed out, this means a class can't easily say "my parent
may well implement ABC, but I don't." That special case could be
added to the default overriding behavior, but ... it starts to get
fragile.
-jJ
More information about the Python-3000
mailing list