4 ms·
> if you just implement `__instancecheck__` directly The point of the article is that to override what "isinstance(obj, ClassA)" means one doesn't need to touc
by Joker_vD 4y ago
> if you just implement `__instancecheck__` directly
The point of the article is that to override what "isinstance(obj, ClassA)" means one doesn't need to touch ClassA, or any descendants of it, at all.
- nadavr 4y agoCan you help me understand what you mean here? The author manages to make something match `case NotIterable()` by...modifying the `NotIterable(ABC)` class. That's exactly what I would have expected. What you mean by "one doesn't need to touch ClassA, or any descendants of it, at all."?
- w-m 4y agoNot quite! The point of the article is that you don’t need to change the class of obj to override this instance check. If you have a look, ClassA always uses the hook implementation in the examples. And this can be shortened to just using instancecheck.
- cryptonector 4y agoRight, but, what's the problem with that?