This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年06月26日 09:49 by Luc Saffre, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg245841 - (view) | Author: Luc Saffre (Luc Saffre) | Date: 2015年06月26日 09:49 | |
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. |
|||
| msg245843 - (view) | Author: Steven D'Aprano (steven.daprano) * (Python committer) | Date: 2015年06月26日 09:58 | |
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. |
|||
| msg245870 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2015年06月26日 21:20 | |
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 |
|||
| msg245871 - (view) | Author: Steven D'Aprano (steven.daprano) * (Python committer) | Date: 2015年06月26日 22:15 | |
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) > 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. |
|||
| msg245875 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2015年06月26日 23:42 | |
Right. Close this unless something else is offered. |
|||
| msg246058 - (view) | Author: Steven D'Aprano (steven.daprano) * (Python committer) | Date: 2015年07月02日 03:58 | |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:18 | admin | set | github: 68703 |
| 2015年07月02日 03:58:15 | steven.daprano | set | status: open -> closed resolution: rejected messages: + msg246058 |
| 2015年06月26日 23:42:41 | terry.reedy | set | messages: + msg245875 |
| 2015年06月26日 22:15:00 | steven.daprano | set | messages: + msg245871 |
| 2015年06月26日 21:20:18 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg245870 versions: + Python 3.4, Python 3.5, Python 3.6 |
| 2015年06月26日 09:58:18 | steven.daprano | set | nosy:
+ steven.daprano messages: + msg245843 |
| 2015年06月26日 09:49:10 | Luc Saffre | create | |