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 2014年09月24日 21:37 by rmccampbell7, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg227489 - (view) | Author: Ryan McCampbell (rmccampbell7) | Date: 2014年09月24日 21:37 | |
Is there a reason register() doesn't check for abstract methods, like subclassing does? Would it fail for some builtin classes? It seems that this would be a better guarantee that, say, something really is iterable when you check isinstance(Collections.Iterable, o), since someone could have called Collections.Iterable.register(o.__class__) without adding an __iter__ method to their class. |
|||
| msg227490 - (view) | Author: Ryan McCampbell (rmccampbell7) | Date: 2014年09月24日 21:41 | |
Obviously, I meant isinstance(o, Collections.Iterable). |
|||
| msg227491 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年09月24日 22:00 | |
Python is a consenting adults language. If you call register, we assume you know what you are doing. The isinstance check, on the other hand, does look in certain cases. So if you define __iter__ you don't have to call register to make isinstance(o, Iterable) be True. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:08 | admin | set | github: 66677 |
| 2014年09月24日 22:00:59 | r.david.murray | set | status: open -> closed nosy: + r.david.murray messages: + msg227491 resolution: not a bug stage: resolved |
| 2014年09月24日 21:41:32 | rmccampbell7 | set | messages: + msg227490 |
| 2014年09月24日 21:37:14 | rmccampbell7 | create | |