[docs] [issue24515] docstring of isinstance
report at bugs.python.org
Sat Jun 27 00:15:00 CEST 2015
Steven D'Aprano added the comment:
On Fri, Jun 26, 2015 at 09:20:18PM +0000, Terry J. Reedy wrote:
> I agree that the tuple explanation if ok. But "Return whether an
> object is an instance of a class or of a subclass thereof." (3.5)
> seems wrong. I believe 'subclass' should be 'superclass'.
No, the current description is correct.
> >>> class C: pass
> >>> class Csub(C): pass
> >>> isinstance(C(), Csub)
In this case, the instance C() is an instance of a *superclass* of
Csub, and isinstance returns False.
> >>> isinstance(Csub(), C)
In this case, the instance Csub() is an instance of a *subclass* of C,
and isinstance returns True.
Python tracker <report at bugs.python.org>
More information about the docs