[issue12203] isinstance not functioning as documented
R. David Murray
report at bugs.python.org
Mon May 30 06:28:10 CEST 2011
R. David Murray <rdmurray at bitdance.com> added the comment:
You are correct, B is not an instance of A. But both B and A are instances of 'type':
>>> class A:
... pass
...
>>> class B(A):
... pass
...
>>> isinstance(A, type)
True
>>> isinstance(B, type)
True
>>>
And type is a subclass of object. isinstance is correct, because Python is consistent. As we said, *everything* is an object.
If you want to know if something is a class, you can check isinstance(X, type):
>>> a = A()
>>> isinstance(a, type)
False
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12203>
_______________________________________
More information about the Python-bugs-list
mailing list