[issue24515] docstring of isinstance
Steven D'Aprano added the comment: Closing. If anyone thinks the docs aren't clear enough, and has an alternate version they would like to suggest, you can re-open it. -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24515] docstring of isinstance
Terry J. Reedy added the comment: 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'. class C: pass class Csub(C): pass isinstance(C(), Csub) False isinstance(Csub(), C) True -- nosy: +terry.reedy versions: +Python 3.4, Python 3.5, Python 3.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24515] docstring of isinstance
New submission from Luc Saffre: The docstring of built-in function 'isinstance' should explain that if the classinfo is a tuple, the object must be instance of *any* (not *all*) of the class objects. -- assignee: docs@python components: Documentation messages: 245841 nosy: Luc Saffre, docs@python priority: normal severity: normal status: open title: docstring of isinstance type: enhancement versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24515] docstring of isinstance
Steven D'Aprano added the comment: It already does: The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for isinstance(x, A) or isinstance(x, B) or ... (etc.). If it were all, it would use and, not or. I don't think any change is needed. Do you have a suggestion for new wording? If not, I'm going to close this issue. -- nosy: +steven.daprano ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24515] docstring of isinstance
Terry J. Reedy added the comment: Right. Close this unless something else is offered. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24515] docstring of isinstance
Steven D'Aprano added the comment: On Fri, Jun 26, 2015 at 09:20:18PM +, 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) False In this case, the instance C() is an instance of a *superclass* of Csub, and isinstance returns False. isinstance(Csub(), C) True In this case, the instance Csub() is an instance of a *subclass* of C, and isinstance returns True. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com